Skip to content

drivine-python

PyPI License

Docs: drivine.org, for Python, TypeScript, and Kotlin & Java.

A graph database client for Python, supporting Neo4j, Memgraph, FalkorDB, Oracle (SQL/PGQ) and Postgres as graph stores, plus Amazon Neptune through the low-level API. Async first, with a sync API written from it, typed, and fast: one statement per round trip, no session cache, no lazy loading. It gives you two ways to work with a graph:

  1. PersistenceManager: a low-level API where you write the queries yourself.
  2. Object manager (StatelessGraphObjectManager): a high-level API that maps Pydantic models, with a query DSL whose typed references are stubs generated from your models.

Neptune connects for the PersistenceManager; the object manager runs on the others. Cypher you write runs on Postgres, Oracle and SQLite too, compiled to SQL: see Cypher on a relational database. 0.8 is an alpha release: the API may still change. See the design for how it came about.

On Node.js or the JVM? Drivine (npm install @liberation-data/drivine) and drivine4j (org.drivine:drivine4j) are its TypeScript and Kotlin & Java twins, with the same object manager, query DSL, schema management and engines. The three share a storage format: a store written from any of them is read, stamped and checked alike by the others.

pip install "drivine[neo4j]" # Neo4j, Memgraph, Neptune
pip install "drivine[falkordb]" # FalkorDB
pip install "drivine[oracle]" # Oracle 23.9 or later, through python-oracledb in thin mode
pip install "drivine[postgres]" # Postgres 14 or later, through psycopg 3
pip install "drivine[sqlite]" # SQLite, a graph in a file, through apsw and the SQLite it bundles
pip install "drivine[neo4j,compiler]" # full-text search (load_matching) on a graph engine

The SQL stores’ extras also install drivine-cypher-compiler, the shared Cypher compiler, which has no wheel for an Intel Mac or musl Linux (Alpine): see Cypher on a relational database.

Python 3.11 or newer. pi-pilgrim, which DrivineAssembly is written with, comes with each; drivine[pilgrim] still installs, as it did when pi-pilgrim was an extra.