colliery-io/graphqlite
A SQLite extension that adds graph database capabilities with Cypher query language support and built-in graph algorithms.
What is GraphQLite?
GraphQLite is an SQLite extension that lets you store and query graph‑structured data inside a regular SQLite database. It brings the Cypher query language (the language used by Neo4j and other graph databases) to SQLite, so you can write expressive graph queries without running a separate graph‑database server.
Why it matters for AI/ML
Many AI applications – especially those that involve knowledge graphs, retrieval‑augmented generation (RAG), or relationship‑heavy data – need a fast way to model entities and their connections. GraphQLite gives you:
- Zero‑config, single‑file storage – SQLite’s portable file format works on laptops, edge devices, and cloud containers.
- Cypher compatibility – You can reuse existing Cypher queries, tutorials, and algorithms that are common in graph‑AI pipelines.
- Built‑in graph algorithms – PageRank, Louvain community detection, Dijkstra shortest‑path, BFS/DFS, etc., are ready to run directly on the data, which is handy for graph‑based feature engineering or reasoning.
Core features (as described in the README)
| Feature | What it does |
|---|---|
| Cypher queries | Supports the main Cypher clauses: MATCH, CREATE, MERGE, SET, DELETE, WITH, UNWIND, RETURN. |
| Graph algorithms | Ready‑to‑use implementations of PageRank, Louvain community detection, Dijkstra shortest‑path, BFS/DFS, connected components, and more. |
| Zero configuration | Works with any SQLite file; no separate server or complex setup. |
| Multiple language bindings | Python (pip install graphqlite), Rust (cargo add graphqlite), and a raw SQL interface. |
| openCypher conformance | Tested against the openCypher TCK with ~98.5 % coverage across 3,880 scenarios. |
How to get started (quick‑start example)
from graphqlite import Graph
g = Graph(":memory:") # create an in‑memory SQLite DB
g.upsert_node("alice", {"name": "Alice", "age": 30}, label="Person")
g.upsert_node("bob", {"name": "Bob", "age": 25}, label="Person")
g.upsert_edge("alice", "bob", {"since": 2020}, rel_type="KNOWS")
# Run a Cypher query
results = g.query(
"MATCH (a:Person)-[:KNOWS]->(b) RETURN a.name, b.name"
)
# Run built‑in algorithms
pagerank = g.pagerank()
communities = g.louvain()
shortest = g.dijkstra("alice", "bob")
The same functionality is available from Rust or via plain SQL statements once the extension is loaded.
Example use case – Graph‑RAG for LLMs
The repository includes an example called GraphRAG that shows how to ingest a dataset (e.g., HotpotQA) into a graph, then query it with a language model:
cd examples/llm-graphrag
uv sync && uv run python ingest.py # build the graph from the dataset
uv run python rag.py "Were Scott Derrickson and Ed Wood of the same nationality?"
This demonstrates a typical AI workflow where a knowledge graph built with GraphQLite is used as a retrieval source for a large language model.
Documentation & community
- Full docs: https://colliery-io.github.io/graphqlite/ – includes tutorials, API reference, and a testing coverage matrix.
- License: MIT (permissive, suitable for commercial and research projects).
TL;DR
GraphQLite turns SQLite into a graph‑database engine with Cypher support and built‑in graph algorithms, available through Python and Rust bindings. It’s a lightweight, zero‑config option for AI/ML projects that need graph storage, fast retrieval, or algorithmic analysis without the overhead of a separate graph‑DB server.
Related
- Dispatch
- Project
- Project
- Project
- Project