The SQLite connector is a file connector that queries a local SQLite database
and maps rows to claims. It uses Python’s built-in sqlite3 module —
zero external dependencies required.
.db or .sqlite file using Python stdlib sqlite3sqlite3.Row factory for named column accesssqlite:{path}| Feature | Description |
|---|---|
| Zero dependencies | Uses Python stdlib sqlite3 — nothing to install. |
| Full SQL | Any valid SQLite query works: joins, subqueries, CTEs, aggregations. |
| Column mapping | Map any result column to subject, predicate, object, and optional type fields. |
| Read-only | Opens the database in read-only mode. No writes to your data. |
The SQLite connector uses Python’s built-in sqlite3 module.
There is nothing to install.
You need a .db or .sqlite file with the table or view you want to query.
Know the schema so you can write a query and define your column mapping.
conn = db.connect("sqlite", path="data/interactions.db", query="SELECT gene, relation, target FROM interactions", mapping={"subject": "gene", "predicate": "relation", "object": "target"}, ) result = conn.run(db)
| Parameter | Required | Default | Description |
|---|---|---|---|
path |
Yes | — | Path to the SQLite database file |
query |
Yes | — | SQL query to execute |
mapping |
Yes | — | Column-to-claim field mapping (dict) |
source_type |
No | database_import |
Provenance source type |
save |
No | False |
N/A (no credentials to store) |
The mapping dict maps claim fields to column names in your query result:
| Claim field | Required | Description |
|---|---|---|
subject | Yes | Column containing the subject entity |
predicate | Yes | Column containing the predicate (relationship) |
object | Yes | Column containing the object entity |
subject_type | No | Column or literal string for subject entity type |
object_type | No | Column or literal string for object entity type |
conn = db.connect("sqlite", path="data/interactions.db", query="SELECT gene, relation, target FROM interactions", mapping={"subject": "gene", "predicate": "relation", "object": "target"}, ) result = conn.run(db)
conn = db.connect("sqlite", path="data/knowledge.db", query=""" SELECT e1.name AS src, r.type AS rel, e2.name AS dst FROM relationships r JOIN entities e1 ON r.source_id = e1.id JOIN entities e2 ON r.target_id = e2.id """, mapping={"subject": "src", "predicate": "rel", "object": "dst"}, ) result = conn.run(db)
conn = db.connect("sqlite", path="data/bio.db", query="SELECT drug, action, gene FROM drug_targets", mapping={ "subject": "drug", "predicate": "action", "object": "gene", "subject_type": "compound", "object_type": "gene", }, ) result = conn.run(db)