Values#

The values the driver reads and the wrappers it sends. All are importable from agensgraph.

Graph values#

See Graph values.

class agensgraph.Vertex#

A vertex. Read-only, compared and hashed on its identity.

property id: GraphId#

Its identity, a GraphId.

property label: str#

The label it was created with.

property properties: dict[str, Any]#

Its property map, a dict, decoded on first access.

get(key: str, default: Any = None) → Any#

One property, or default.

properties_json() → bytes#

The property map as JSON bytes, without decoding it if nothing has.

class agensgraph.Edge#

An edge: everything a Vertex has, plus its endpoints.

property start: GraphId#

The identity of the vertex it leaves.

property end: GraphId#

The identity of the vertex it enters.

class agensgraph.Path(vertices: tuple[Vertex, ...], edges: tuple[Edge, ...])#

A path: a sequence of vertex, edge, vertex, and so on. len() is the number of elements.

property vertices: tuple[Vertex, ...]#

Its vertices, in order.

property edges: tuple[Edge, ...]#

Its edges, in order.

property elements: tuple[Vertex | Edge, ...]#

Vertices and edges interleaved.

property start: Vertex | None#

The first vertex, or None for an empty path.

property end: Vertex | None#

The last vertex, or None for an empty path.

property length: int#

The number of hops: of edges.

class agensgraph.GraphId(labid: int, locid: int)#

An element’s identity: the label’s id and the element’s number within the label. Prints as labid.locid, orders as the server does, and is sent as a graphid.

labid#

The label’s id, up to LABID_MAX.

locid#

The element’s number in the label, up to LOCID_MAX.

property packed: int#

The 64-bit integer the server stores.

classmethod from_packed(packed: int) → GraphId#

A GraphId from its packed integer.

agensgraph.LABID_MAX = 65535#

The largest label id.

agensgraph.LOCID_MAX = 281474976710655#

The largest element number within a label.

Values you send#

See Parameters.

class agensgraph.Unspecified(value: str)#

A string sent with no type, for the server to infer from where it is used: psycopg’s default behaviour, for plain SQL. Not for Cypher, where an untyped string is parsed as JSON.

class agensgraph.Jsonb(obj: Any)#

psycopg’s wrapper, re-exported: send any JSON value as jsonb, such as a list for UNWIND %s.

class agensgraph.Label(name: str)#

A str subclass for a label or property name. It is not quoted for you: put a name into a statement with agensgraph.cypher.quote_identifier().

Numbers#

See Numbers.

agensgraph.read_numbers_exactly(enabled: bool = True)#

Read every non-integer in a property map or a jsonb column as a Decimal, for the whole process. Set it once, at startup.

agensgraph.reading_numbers_exactly() → bool#

Whether non-integers are read as Decimal.

JSON#

See Handing values to something that wants JSON.

agensgraph.to_json(obj: Any) → bytes#

JSON bytes for a value, a row or a result, copying property maps nobody read as the bytes they arrived in.

agensgraph.to_builtins(obj: Any) → Any#

One graph value as dicts and lists.

agensgraph.json_default(obj: Any) → Any#

A default= hook for json.dumps.

Notifications#

class agensgraph.Notify#

psycopg’s notification, re-exported: what notifications() yields and a notify handler receives.

channel: str#
payload: str#
pid: int#

the process id of the session that sent it