Schema Classes

class NodeType(label, *properties, extra_labels=())

The core of the low-level QueryBuilder API. Represents a group of nodes with a common label and, optionally, common properties.

Parameters:
  • label (str) – The primary label that defines the NodeType.
  • properties (Property) – The Property objects associated with the NodeType.
  • extra_labels (iterable) – Secondary labels shared by the NodeType.
LABEL

The primary label that defines the NodeType.

labels

The set of all labels shared by the NodeType’s members.

class Property(name=None, type=str, default=None, indexed=False, unique=False, required=False)

Represents an optionally constrained property on a NodeType.

Parameters:
  • name (str) – The name of the property on the node.
  • type (callable) – Any callable used to convert a property value’s type. Typically a built-in Python type.
  • default – The default value for the property if not specified.
  • indexed (bool) – If set, create an index for the property.
  • unique (bool) – If set, create a unique constraint for the property. This implies indexed=True.
  • required (bool) – If set, create a property existence constraint for the property. Only available with Neo4J Enterprise.
class Graph
delete_all()

Issues MATCH (all) DETACH DELETE all, completely clearing the graph.

It should go without saying that this will delete all of your data!

query(query, **params)

Run an arbitrary query against the graph, with optional parameters.

When not called, returns a reference to the Graph’s Query object.

Parameters:
  • query – An object that stringifies to a Cypher query.
  • params – The values for the query’s parameters.
Returns:

A Neo4J StatementResult corresponding to the issued query.

Return type:

neo4j.v1.StatementResult

schema

A reference to the Graph’s Schema object.

session()

Returns a session from the underlying driver‘s pool.

class graph.query
all()

Returns the result of MATCH (all) RETURN all.

log(query, params)

Log the given query and parameters. For other options, see graph.query.log.

class graph.query.log
MAX_SIZE

int The maximum number of log entries to store.

class graph.schema
add(nodetype, overwrite=False)

Add a NodeType to the schema.

Parameters:
  • nodetype (NodeType) – The NodeType instance to add to the schema
  • overwrite (bool) – If set, DROP and re-CREATE any existing schema
Return type:

None

constraints

Get current graph constraints lazily.

On first access, this fetches from the database. Afterwards, call update() to refresh.

indexes

Get current graph indexes lazily.

On first access, this fetches from the database. Afterwards, call update() to refresh.

labels

Get current graph labels lazily.

On first access, this fetches from the database. Afterwards, call update() to refresh.

ls

Cypher statements for currently defined schema.

update()

Refresh constraints, indexes, and labels.