Schema#

Catalog rows and declarations, importable from agensgraph. The methods that return and take them are on Connection.

Catalog rows#

See Inspecting a graph.

class agensgraph.Graph(name: str, schema: str, labels: int)#

A graph.

name: str#
schema: str#

the schema it is stored in

labels: int#

how many labels it has, built-ins included

class agensgraph.LabelInfo(id: int, name: str, kind: str, parent: str | None)#

A label. Prints as Label.

id: int#

the label’s id, the first number of its elements’ identities

name: str#

as stored

kind: str#

'v' or 'e'

parent: str | None#

the label it inherits from

property is_vertex: bool#
property is_edge: bool#
property is_builtin: bool#

ag_vertex or ag_edge.

class agensgraph.DeclaredProperty(
label: str,
name: str,
type: str,
nullable: bool,
inherited: bool = False,
)#

A property kept in a column of its own.

label: str#
name: str#
type: str#

the server’s spelling of its type

nullable: bool#
inherited: bool#

whether it comes from the label’s parent

class agensgraph.Index(label: str, name: str, unique: bool, definition: str)#

A property index.

label: str#
name: str#
unique: bool#
definition: str#

the statement that would create it again

class agensgraph.Constraint(label: str, name: str, unique: bool, definition: str)#

A uniqueness or check constraint.

label: str#
name: str#
unique: bool#

true for a uniqueness constraint

definition: str#

the server’s normalised rendering

class agensgraph.GraphDescription(
graph: str,
labels: tuple[Label, ...],
properties: dict[str, tuple[PropertyShape, ...]],
triples: tuple[Triple, ...],
counts: dict[str, int],
meta_gathered: bool,
)#

What describe() returns.

graph: str#
labels: tuple[Label, ...]#

every label, as LabelInfo

properties: dict[str, tuple[PropertyShape, ...]]#

for each label but the built-ins, its properties as PropertyShapes

triples: tuple[Triple, ...]#

which labels each edge label connects

counts: dict[str, int]#

elements per label

meta_gathered: bool#

whether triples is current

class agensgraph.PropertyShape(name: str, kind: str, declared: bool)#

A property seen on a label.

name: str#
kind: str#

its JSON type, with numbers as integer or float, or a declared column’s type

declared: bool#

whether it has a column of its own

class agensgraph.Triple(start: str, edge: str, end: str, edge_count: int)#

An edge label and the labels it connects.

start: str#
edge: str#
end: str#
edge_count: int#

Declarations#

See Declaring a schema.

class agensgraph.DesiredLabel(
name: str,
kind: str = 'v',
parent: str | None = None,
properties: Sequence[PromotedProperty] = (),
)#

A label that should exist.

name: str#
kind: str#

'v' or 'e'

parent: str | None#

the label to inherit from

properties: Sequence[PromotedProperty]#

PromotedPropertys to keep in columns of their own

class agensgraph.PromotedProperty(name: str, type: str)#

A property to keep in a column of its own.

name: str#
type: str#

the column type, written into the statement as given

rendered() → str#

The column’s definition.

class agensgraph.DesiredIndex(
label: str,
properties: tuple[str | IndexElement, ...],
unique: bool = False,
name: str | None = None,
method: str = 'btree',
where: str | None = None,
)#

A property index that should exist.

label: str#
properties: tuple[str | IndexElement, ...]#

names, or IndexElements

unique: bool#
name: str | None#

required with where

method: str#

btree, gin, hnsw, …

where: str | None#

a partial index’s predicate

property elements: tuple[IndexElement, ...]#

properties as IndexElements.

key() → tuple[str, str, tuple[IndexElement, ...]]#

What an index is matched on.

class agensgraph.IndexElement(
property: str,
operator_class: str | None = None,
descending: bool = False,
nulls_first: bool | None = None,
cast: str | None = None,
)#

One property of an index.

property: str#
operator_class: str | None#

only when not the default

descending: bool#
nulls_first: bool | None#

None for the default

cast: str | None#

a type to index the property as, such as vector(4)

rendered() → str#
resolved() → IndexElement#

The same with nulls_first made explicit.

nulls_come_first() → bool#
class agensgraph.Unique(label: str, property: str, name: str | None = None)#

A uniqueness constraint. Named <label>_<property>_unique without a name.

label: str#
property: str#
name: str | None#
class agensgraph.Check(label: str, expression: str, name: str)#

A check constraint over a Cypher expression. Its name is required.

label: str#
expression: str#
name: str#

Statements without a connection#

agensgraph.create_label_statement(
name: str,
kind: str,
parent: str | None = None,
properties: Sequence[PromotedProperty] = (),
) → str#

create vlabel or create elabel, if not exists.

agensgraph.create_index_statement(desired: DesiredIndex, *, if_not_exists: bool = False) → str#

create property index; with if_not_exists, which needs a name.

agensgraph.create_constraint_statement(desired: Unique | Check) → str#

create constraint. The server has no if not exists for one.