Installation
GraphQLite is a SQLite extension that adds Cypher graph query support. It can be used from Python, Rust, the command line, or any language that can load SQLite extensions.
Python (Recommended)
Section titled “Python (Recommended)”Install from PyPI:
pip install graphqliteThis installs pre-built binaries for:
- macOS (arm64, x86_64)
- Linux (x86_64, aarch64)
- Windows (x86_64)
Optional Dependencies
Section titled “Optional Dependencies”The Leiden community detection algorithm requires graspologic:
pip install graphqlite[leiden]For rustworkx-powered graph export:
pip install graphqlite[rustworkx]Install everything:
pip install graphqlite[leiden,rustworkx]Add to your Cargo.toml:
[dependencies]graphqlite = "0.3"The bundled-extension feature is enabled by default. It bundles the compiled extension directly into your binary so no separate .so/.dylib file is needed at runtime:
[dependencies]graphqlite = { version = "0.3", features = ["bundled-extension"] }To use an external extension at runtime instead, disable the default features:
[dependencies]graphqlite = { version = "0.3", default-features = false }From Source
Section titled “From Source”Building from source produces the raw extension file you can load into any SQLite environment.
Prerequisites
Section titled “Prerequisites”| Tool | Minimum Version | Purpose |
|---|---|---|
| GCC or Clang | 9+ | C compiler |
| Bison | 3.0+ | Parser generator |
| Flex | 2.6+ | Lexer generator |
| SQLite development headers | 3.35+ | SQLite API |
| CUnit | 2.1+ | Unit tests (optional) |
brew install bison flex sqlite cunitexport PATH="$(brew --prefix bison)/bin:$PATH"git clone https://github.com/colliery-io/graphqlitecd graphqlitemake extensionHomebrew installs a newer Bison than the one shipped with macOS. The PATH export ensures the build system picks up the correct version.
Linux (Debian/Ubuntu)
Section titled “Linux (Debian/Ubuntu)”sudo apt-get install build-essential bison flex libsqlite3-dev libcunit1-devgit clone https://github.com/colliery-io/graphqlitecd graphqlitemake extensionWindows (MSYS2)
Section titled “Windows (MSYS2)”pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-sqlite3 bison flex makegit clone https://github.com/colliery-io/graphqlitecd graphqlitemake extensionDebug vs. Release Build
Section titled “Debug vs. Release Build”The default build includes debug symbols and assertions. For a release build:
make extension RELEASE=1Release builds enable -O2 optimization and strip assertions. Use them for production deployments.
Output Files
Section titled “Output Files”After building, the extension appears in build/:
| Platform | File |
|---|---|
| macOS | build/graphqlite.dylib |
| Linux | build/graphqlite.so |
| Windows | build/graphqlite.dll |
See Building from Source for the full list of build targets and how to run tests.
Verifying Installation
Section titled “Verifying Installation”Python
Section titled “Python”import graphqlite
# Check versionprint(graphqlite.__version__)
# Quick smoke testfrom graphqlite import Graph
g = Graph(":memory:")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")
print(g.stats()) # {'nodes': 2, 'edges': 1}print(g.query("MATCH (n:Person) RETURN n.name ORDER BY n.name"))use graphqlite::Connection;
fn main() -> graphqlite::Result<()> { let conn = Connection::open_in_memory()?; conn.cypher("CREATE (n:Person {name: 'Alice'})")?; let rows = conn.cypher("MATCH (n:Person) RETURN n.name")?; for row in &rows { println!("{}", row.get::<String>("n.name")?); } Ok(())}SQL (raw SQLite)
Section titled “SQL (raw SQLite)”sqlite3.load /path/to/build/graphqliteSELECT cypher('RETURN 1 + 1 AS result');SELECT cypher('CREATE (n:Test {value: 42})');SELECT cypher('MATCH (n:Test) RETURN n.value');Extension Path Configuration
Section titled “Extension Path Configuration”When GraphQLite cannot find the extension automatically, specify the path explicitly.
Environment Variable
Section titled “Environment Variable”Set GRAPHQLITE_EXTENSION_PATH before running your application:
export GRAPHQLITE_EXTENSION_PATH=/path/to/build/graphqlite.dylibpython my_app.pyThis works for Python, the CLI (gqlite), and any program that reads environment variables before loading the extension.
Python: Explicit Path
Section titled “Python: Explicit Path”from graphqlite import connect, Graph, GraphManager
# connect()conn = connect("graph.db", extension_path="/path/to/graphqlite.dylib")
# Graph()g = Graph("graph.db", extension_path="/path/to/graphqlite.dylib")
# GraphManager / graphs()from graphqlite import graphswith graphs("./data", extension_path="/path/to/graphqlite.dylib") as gm: social = gm.open_or_create("social")Finding the Bundled Path
Section titled “Finding the Bundled Path”When using the Python package, GraphQLite ships a bundled extension. Get its path:
import graphqlite
path = graphqlite.loadable_path()print(path) # e.g. /usr/local/lib/python3.12/site-packages/graphqlite/graphqlite.dylibYou can pass this path to other tools or languages that need to load the extension manually.
Platform Notes
Section titled “Platform Notes”-
The extension is a Mach-O shared library with the
.dylibsuffix. -
If you see
Library not loadederrors, ensure you are using Homebrew’s SQLite rather than the system SQLite:Terminal window export DYLD_LIBRARY_PATH="$(brew --prefix sqlite)/lib:$DYLD_LIBRARY_PATH" -
Apple Silicon (M1/M2/M3) and Intel builds are separate; PyPI ships a universal wheel containing both.
- The extension is an ELF shared object with the
.sosuffix. - Make sure
libsqlite3is installed at runtime (not justlibsqlite3-dev). - On musl-based systems (Alpine Linux), build from source.
Windows
Section titled “Windows”- The extension is a DLL with the
.dllsuffix. - Load it with the full path:
.load C:/path/to/graphqlite. - MSYS2 or WSL are the supported build environments.
Troubleshooting
Section titled “Troubleshooting”Extension not found (Python)
Section titled “Extension not found (Python)”FileNotFoundError: GraphQLite extension not foundEither the package was installed without wheels for your platform, or the environment variable points to the wrong file. Try:
import graphqliteprint(graphqlite.loadable_path()) # See where Python looksThen set GRAPHQLITE_EXTENSION_PATH or pass extension_path explicitly.
Python sqlite3 extension support disabled
Section titled “Python sqlite3 extension support disabled”Some Python distributions compile sqlite3 without extension loading support (e.g., certain Docker images):
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'Rebuild Python from source with --enable-loadable-sqlite-extensions, or switch to a distribution that includes it (standard CPython builds from python.org do support it).
Version mismatch
Section titled “Version mismatch”If you see unexpected query errors after upgrading, ensure the Python package and the loaded extension are from the same version:
import graphqliteprint(graphqlite.__version__) # Python package versionWhen building from source for use with the Rust crate, run make install-bundled after make extension to replace the bundled binary in the Rust crate’s source tree.
SQLite version too old
Section titled “SQLite version too old”GraphQLite requires SQLite 3.35 or later for JSON function support. Check your SQLite version:
import sqlite3print(sqlite3.sqlite_version) # Should be 3.35.0 or higher