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.2.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.2-py3-none-any.whl (38.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sonnet_graph-0.3.2.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.2.tar.gz
Algorithm Hash digest
SHA256 89befc15d768fb6e6beceb86da60cdfab934d6d8f2892cf7b868bdfad689c405
MD5 1dd87fc9012eb039d09798858afc1714
BLAKE2b-256 f2f6be0784db481c089ae5a624ec3d068dd7d684d1be913256b43b98d00f9cdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_graph-0.3.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: sonnet_graph-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 38.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 56e63e4057f1b94df7a4f0fbf88d903d203b3e6a8fe2345b57acad6ae7237b1b
MD5 f621aca1512863716ea93f72aef61cbf
BLAKE2b-256 f1aecb04d5c4148b9e03f914d8ad719c32b06201c34a30dc467f3fa43a050d77

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_graph-0.3.2-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

0.3.3

2 files

This release

0.3.2 This release

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