This is the API documentation for mgp.py
which contains definitions of the public Python API provided by Memgraph. In essence, this is a wrapper around the [C API](mg_procedure.md)
. This source file can be found in the Memgraph installation directory, under python_support
. On the standard Debian installation, this will be under /usr/lib/memgraph/python_support
.
| Name |
method | mgp.read_proc Register a function as a read-only procedure of the current module. |
exception | mgp.AbortError Signals that the procedure was asked to abort its execution. |
class | mgp.Deprecated Annotate a resulting Record’s field as deprecated. |
class | mgp.Edge Edge in the graph database. |
class | mgp.EdgeType Type of an Edge. |
class | mgp.Graph State of the graph database in current ProcCtx. |
class | mgp.Label Label of a Vertex. |
class | mgp.Path Path containing Vertex and Edge instances. |
class | mgp.ProcCtx Context of a procedure being executed. |
class | mgp.Properties A collection of properties either on a Vertex or an Edge. |
class | mgp.Property Named property value of a Vertex or an Edge. |
class | mgp.Record Represents a record of resulting field values. |
class | mgp.Vertex Vertex in the graph database. |
class | mgp.Vertices Iterable over vertices in a graph. |
Register func
as a read-only procedure of the current module.
read_proc
is meant to be used as a decorator function to register module procedures. The registered func
needs to be a callable which optionally takes ProcCtx
as the first argument. Other arguments of func
will be bound to values passed in the cypherQuery. The full signature of func
needs to be annotated with types. The return type must be Record(field_name=type, ...)
and the procedure must produce either a complete Record or None. To mark a field as deprecated, use Record(field_name=Deprecated(type), ...)
. Multiple records can be produced by returning an iterable of them. Registering generator functions is currently not supported.
Bases: Exception
Signals that the procedure was asked to abort its execution.
Bases: object
Annotate a resulting Record’s field as deprecated.
Bases: object
Edge in the graph database.
Access to an Edge is only valid during a single execution of a procedure in a query. You should not globally store an instance of an Edge. Using an invalid Edge instance will raise InvalidContextError.
Raise InvalidContextError.
Raise InvalidContextError.
Return True if self is in valid context and may be used.
Raise InvalidContextError.
Raise InvalidContextError.
Raise InvalidContextError.
Bases: object
Type of an Edge.
Bases: object
State of the graph database in current ProcCtx.
Return the Vertex corresponding to given vertex_id from the graph.
Access to a Vertex is only valid during a single execution of a procedure in a query. You should not globally store the returned Vertex.
Raise IndexError if unable to find the given vertex_id. Raise InvalidContextError if context is invalid.
Return True if self is in valid context and may be used.
All vertices in the graph.
Access to a Vertex is only valid during a single execution of a procedure in a query. You should not globally store the returned Vertex instances.
Raise InvalidContextError if context is invalid.
Bases: Exception
Signals using a graph element instance outside of the registered procedure.
Bases: object
Label of a Vertex.
Bases: object
Path containing Vertex and Edge instances.
Edges ordered from the start to the end of the path.
Raise InvalidContextError if using an invalid Path instance.
Append an edge continuing from the last vertex on the path.
The last vertex on the path will become the other endpoint of the given edge, as continued from the current last vertex.
Raise ValueError if the current last vertex in the path is not part of the given edge. Raise InvalidContextError if using an invalid Path instance or if passed in edge is invalid.
Vertices ordered from the start to the end of the path.
Raise InvalidContextError if using an invalid Path instance.
Bases: object
Context of a procedure being executed.
Access to a ProcCtx is only valid during a single execution of a procedure in a query. You should not globally store a ProcCtx instance.
Raise InvalidContextError if context is invalid.
Bases: object
A collection of properties either on a Vertex or an Edge.
Get the value of a property with the given name or return default.
Raise InvalidContextError.
Raise InvalidContextError.
Iterate over property names.
Raise InvalidContextError.
Iterate over property values.
Raise InvalidContextError.
Bases: tuple
Named property value of a Vertex or an Edge.
Alias for field number 0
Alias for field number 1
Bases: object
Represents a record of resulting field values.
Bases: Exception
Signals a typing annotation is not supported as a _mgp.CypherType.
Bases: object
Vertex in the graph database.
Access to a Vertex is only valid during a single execution of a procedure in a query. You should not globally store an instance of a Vertex. Using an invalid Vertex instance will raise InvalidContextError.
Raise InvalidContextError.
Raise InvalidContextError.
Return True if self is in valid context and may be used
Raise InvalidContextError.
Raise InvalidContextError.
Raise InvalidContextError.
Bases: object
Iterable over vertices in a graph.
Return True if self is in valid context and may be used.