Skip to main content

sonnet-graph

Graph database integration (cypher-graphdb) for sonnet-server applications.

Provides reusable infrastructure for sonnet-server apps that need a cypher-graphdb connection pool:

  • GraphDBExtension -- sonnet-server extension managing pool lifecycle (startup/shutdown), with optional mode for apps where graph is not required.
  • Pool context -- borrow_graphdb() context manager and get_current_graphdb() ambient session accessor via ContextVar.
  • Readiness checks -- GraphdbStage with initialization and health checks for the sonnet-server readiness pipeline.
  • FastAPI dependencies -- get_graphdb_session() async generator for router-level ambient sessions.

Installation

pip install sonnet-graph

Usage

from sonnet_graph import GraphDBExtension, borrow_graphdb, get_current_graphdb

# In app.py -- register the extension
_extension_registry = create_extension_registry(
    DatabaseExtension(),
    GraphDBExtension(),          # required (raises on missing CGDB_* settings)
    GraphDBExtension(optional=True),  # or optional (skips if unconfigured)
    ...
)

# In service code -- borrow a connection
with borrow_graphdb() as db:
    db.execute("MATCH (n) RETURN count(n)")

# In service code -- ambient session (within borrow_graphdb scope)
db = get_current_graphdb()

Configuration

Graph connection is configured via cypher-graphdb's own environment variables (not 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 graph, AGE only (default: false)

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.2.1.tar.gz (30.7 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.2.1-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sonnet_graph-0.2.1.tar.gz
Algorithm Hash digest
SHA256 48de7a12c8e0747636abb5827b4ab41181cb0c1f29d402baa9b638fe05bda8d9
MD5 d88025b11ca12d1d6d67f85ad579f07e
BLAKE2b-256 c65d0c31f59b8248c200dc584e5025900cdea6867772c68527f9047fb38cca5e

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for sonnet_graph-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 093e8f72b65b6a96f5c21bf12d2ed7c4a7b55c39b504a4a4c2a920c1dd798804
MD5 311680bf65306e3d3922fead57c2f22d
BLAKE2b-256 435aa26cf7370e4da116a777c0f72fca4e22073a00e64ff474def1adfb56b046

See more details on using hashes here.

Provenance

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

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

This release

0.2.1 This release

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