Skip to content

Connecting

Describe a database in the environment, with the same variables as TypeScript’s Drivine and drivine4j, so one .env serves an application in any of them:

DATABASE_TYPE=NEO4J
DATABASE_HOST=localhost
DATABASE_PORT=7687
DATABASE_USER=neo4j
DATABASE_PASSWORD=…

A second database takes a prefix, ANALYTICS_DATABASE_TYPE and so on. Then register them:

from drivine import DatabaseRegistry, PersistenceManagerFactory
registry = DatabaseRegistry()
registry.build_or_resolve_from_env() # "default"
registry.build_or_resolve_from_env("analytics") # ANALYTICS_DATABASE_*
pm = PersistenceManagerFactory(registry).get() # the default database
...
await registry.close() # when the application stops

On FalkorDB, DATABASE_NAME names the graph, graph by default.

On Oracle, DATABASE_NAME is the service (FREEPDB1, say), and DATABASE_DEFAULT_GRAPH_PATH names the graph, drivine by default. A graph is drivine4j’s tables, <graph>_node, <graph>_edge and <graph>_schema, and a SQL property graph over them, made on the first connection when they aren’t there, so one store serves the JVM, Node and Python. The object manager writes SQL for it, and the query DSL, grouped reads, search and schema management work as on the graph engines. A raw where is SQL over the node’s row, n: its labels, props (a JSON object keyed by stored name) and stamp, say JSON_VALUE(n.props, '$.name') = $name. Your own statements are SQL too.

Or in code:

registry.builder().database_type(DatabaseType.MEMGRAPH).host("localhost").register("graph")

Drivine reads os.environ, and doesn’t load .env files itself: use python-dotenv, pydantic-settings, or your platform’s way.