Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Drivine: graph database client for TypeScript, Python and the JVM

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.

Cypher you write runs on Postgres and Oracle too, compiled to SQL. 0.3 is an alpha release: the API may still change.

Install

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

Python 3.11 or newer.

Quick start

Describe the database in the environment (DATABASE_TYPE=NEO4J, DATABASE_HOST=localhost, DATABASE_USER, DATABASE_PASSWORD), declare a fragment for a node, then save and load it, each in one statement:

import asyncio
from typing import Annotated

from drivine import DrivineAssembly, NodeFragment, NodeId, refs


class Person(NodeFragment, labels=["Person"]):
    uuid: Annotated[str, NodeId()]
    name: str


async def main() -> None:
    async with DrivineAssembly() as drivine:
        gom = drivine.graph_object_manager()
        await gom.save(Person(uuid="p1", name="Ada"))
        print(await gom.load_all(Person, where=refs(Person).name.eq("Ada")))


asyncio.run(main())

Views that compose fragments and relationships, queries, transactions, schema and the sync API are in the full quick start and the pages after it.

Documentation

License

Apache 2.0.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages