Skip to main content

sonnet-graph

Cypher graph database access for sonnet-server applications. It is the seam between the driver and a running process: pooling, lifecycle, readiness and in-graph metadata.

Version 0.3.1. It wraps cypher-graphdb>=0.5.0 and does not re-abstract it -- query building, result parsing, bulk loading, indexes and the differences between the two backends all stay in the driver. The backends are Apache AGE (on PostgreSQL) and Memgraph.

What it provides

  • GraphDBExtension -- pool lifecycle bound to the sonnet-server application lifecycle, with an optional mode for services where the graph is not required.
  • Pools -- named pools as the addressing scheme, borrow_graphdb() as the entry point and get_current_graphdb() for the ambient connection. Managed mode adds lazy creation and idle reaping when the set of graphs is open-ended.
  • Readiness and status -- GraphdbStage initialization and health checks on the sonnet-core readiness pipeline, plus pool snapshots for operations.
  • FastAPI dependencies -- get_graphdb() and get_graphdb_session() for router-level ambient connections.
  • Typed results -- per-pool model providers so query results come back as your own Pydantic classes.
  • Graph metadata -- stores that keep a graph's schema, documentation and named queries as nodes inside the graph itself.

It defines no SQLModel tables and ships no migrations.

Install

uv add sonnet-graph

Depends on sonnet-core, sonnet-server, cypher-graphdb, loguru and jinja2. The backend drivers arrive with cypher-graphdb, so there is no per-backend extra. The only extra is dev.

Usage

Register the extension once, then borrow a connection from anywhere in the process.

from sonnet_graph import GraphDBExtension, borrow_graphdb

registry = create_extension_registry(
    DatabaseExtension(),
    GraphDBExtension(),
)

with borrow_graphdb() as cdb:
    result = cdb.execute("MATCH (n:Product) RETURN n LIMIT 10")

GraphDBExtension(optional=True) skips startup instead of raising when the graph is unconfigured.

Configuration

The connection is configured through cypher-graphdb's own CGDB_ environment variables rather than being duplicated in consumer settings.

Variable Description
CGDB_BACKEND Backend type: age or memgraph
CGDB_CINFO Connection string / DSN
CGDB_GRAPH Graph name
CGDB_READ_ONLY Read-only mode (default: false)
CGDB_CREATE_GRAPH_IF_NOT_EXISTS Auto-create the graph, AGE only (default: false)

Documentation

License

Apache 2.0 -- see LICENSE.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sonnet_graph-0.3.3.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonnet_graph-0.3.3-py3-none-any.whl (38.7 kB view details)

Uploaded Python 3

File details

Details for the file sonnet_graph-0.3.3.tar.gz.

File metadata

  • Download URL: sonnet_graph-0.3.3.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sonnet_graph-0.3.3.tar.gz
Algorithm Hash digest
SHA256 88dac4149b56db1825999a66b65bf8454af2d59413a696e16ad4d7fe1b6bcdc7
MD5 be862ff18a98d1fe02e39b00bdd70832
BLAKE2b-256 8d71f1737c6e4560377185a3eb36396f77e06a977ff3f8d5c86341906ccdeb9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_graph-0.3.3.tar.gz:

Publisher: publish.yml on petrarca/sonnet-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sonnet_graph-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: sonnet_graph-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sonnet_graph-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0789d55cbbcf3c7275931a69d714d8799d6ff772e72cd32ec1483a0d2b223aa9
MD5 47c2cb6e65b8a5ff2cb2583e204675ce
BLAKE2b-256 87f752a7fe6bf42f9b3862828f31ac9ca6accbd8b26b52343c0235a3665c9494

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_graph-0.3.3-py3-none-any.whl:

Publisher: publish.yml on petrarca/sonnet-server

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page