Utilities#

Observability, quoting, adapters, memory and the DB-API.

Observability#

See Observability.

agensgraph.add_query_logger(callback: Callable[[QueryRecord], None])#

Call callback with a QueryRecord for every statement.

agensgraph.remove_query_logger(callback: Callable[[QueryRecord], None])#
class agensgraph.QueryRecord(
connection: int,
statement: str,
elapsed: float,
rows: int,
failed: bool,
error: BaseException | None = None,
)#

One statement.

connection: int#

an opaque number for the connection

statement: str#

as sent, without parameter values

elapsed: float#

seconds until the server answered

rows: int#
failed: bool#
error: BaseException | None#
agensgraph.enable_tracing(tracer: Any = None)#

Take an OpenTelemetry span per execute_query(). Needs the otel extra.

agensgraph.disable_tracing()#
agensgraph.observability.add_notice_listener(callback: Callable[[Notice], None])#

Call callback with a Notice for every notice the server sends.

agensgraph.observability.remove_notice_listener(callback: Callable[[Notice], None])#
class agensgraph.Notice(
severity: str,
code: str | None,
message: str,
detail: str | None = None,
hint: str | None = None,
)#

A notice.

severity: str#

not localised

code: str | None#

the SQLSTATE

message: str#
detail: str | None#
hint: str | None#

Quoting#

See Identifiers.

agensgraph.cypher.quote_identifier(name: str) → str#

A name as an identifier, quoted unless the server would read it unchanged.

agensgraph.cypher.quote_string(value: str) → str#

A string literal.

agensgraph.cypher.check_single_statement(statement: str)#

Raise ValueError if the text holds more than one statement.

agensgraph.cypher.check_can_wrap(statement: str)#

Raise ValueError if the text holds a write clause. A hint, not a boundary.

Adapters#

See Other tools.

agensgraph.adapters.register_text(context: AdaptContext | AdaptersMap, labels: LabelCache | None = None)#

Read graph values in the text rendering on a psycopg connection, and send values the driver’s way.

agensgraph.adapters.assert_oids(conn: Connection[Any])#

Check the graph types’ oids against a server.

Bulk loading and memory#

See Bulk loading.

class agensgraph.bulk.UpsertCounts(inserted: int, updated: int)#

What an upsert wrote.

inserted: int#
updated: int#
agensgraph.paused_collection() → Generator[None]#

A block during which Python’s cycle collector does not run.

agensgraph.freeze_after_import()#

Move every object alive now out of the collector’s way. Once, at startup.

DB-API#

See Other tools.

agensgraph.dbapi.connect(dsn: str = '', **kwargs: object) → Connection[object]#

agensgraph.connect(), under PEP 249’s name. The module also has apilevel, threadsafety, paramstyle, the type constructors and the exception classes.