Skip to content

Sync

drivine.sync is the same API without async and await, for scripts, notebooks, Django and Flask:

from drivine.sync import DatabaseRegistry, PersistenceManagerFactory, StatelessGraphObjectManager, transactional
registry = DatabaseRegistry()
registry.build_or_resolve_from_env()
gom = StatelessGraphObjectManager(PersistenceManagerFactory(registry).get())
@transactional
def promote(uuid: str) -> None:
person = gom.load(Person, uuid)
gom.save(person.model_copy(update={"bio": "Lead"}))
  • Each driver’s own sync client, not an event loop behind the scenes: it costs nothing extra, and works where a loop is already running, as in Jupyter.
  • The same models, query DSL and backends. A class is one class in both APIs; only what does I/O is sync.
  • Each thread has its own transaction, as asyncio gives each task’s context its own.
  • @transactional from drivine.sync takes a plain function, and drivine’s takes an async one.

It is written from the async source by scripts/unasync.py, as the Neo4j driver writes its sync API, and tested by the same tests, written alike.