Schema Classes¶
-
class
GraphObject
(graph=None, **properties)¶ The base class for
Node
andRelationship
Parameters: -
bind
(*keys)¶
Parameters: keys (str) – The names of properties to bind to. If none are provided, the default is to bind to all Properties marked as primary keys, if any. -
bound_keys
¶ A tuple representing the keys to which the object is currently bound.
-
is_bound
¶ A boolean indicating whether or not the object is bound. This can be True even if bound_keys is empty.
-
properties
¶ A dict representing properties and their current values. Note that editing this dict does not set properties!
-
keys
()¶ A dict-like method providing a tuple of names of attributes which correspond to Properties.
-
-
class
Node
(*labels, **properties)¶ The core of the low-level QueryBuilder API. Represents a Node in Neo4J along with its labels and properties.
Parameters: - labels (str) – The labels for the Node. These should be defined from least to most specific.
- var (str) – The Cypher variable representing the node.
- properties (Property) – The
Property
objects associated with the Node. String arguments are automatically converted into Property objects of the default string type.
-
type
¶ The primary label that defines the Node.
-
labels
¶ The set of all labels shared by the Node’s members.
-
class
Relationship
(type, start_node=None, end_node=None, depth=None, directed=True, var='rel', **properties)¶ Parameters: - type (str) – The relationship’s type, which in NeoAlchemy is required.
- start_node (Node) – The node represented by a, in
(a)-[:TYPE]->(b)
. - end_node (Node) – The node represented by b, in
(a)-[:TYPE]->(b)
. - depth – A variable property to control the depth of the relationship
when used as part of a Cypher statement.
-1
indicates “infinite” depth (*
), any positive integern
represents that depth (*n
), and any tuple of positive integers(m, n)
represents a range (*m..n
). - directed (bool) – Whether or not the relation is directed. Default is True (directed relation). Note that some operations (such as merge) become effectively arbitrary on undirected relationships. This is a limitation of Neo4J.
- var (str) – The Cypher variable representing the relationship.
- properties (Property) – The
Property
objects associated with the Node. String arguments are automatically converted into Property objects of the default string type.
-
exists
(exists=True)¶
Returns a CypherExpression corresponding to the
EXISTS
function in Cypher.Parameters: exists (bool) – If False, do NOT EXISTS
instead. Default is True.
-
class
Property
(obj=None, type=str, default=None, value=None, indexed=False, unique=False, required=False, primary_key=False, read_only=False)¶ Represents an optionally constrained property on a
GraphObject
.Parameters: - obj (GraphObject) – The object to which the Property will be bound.
- type (callable) – Any callable used to convert a property value’s type.
Typically a built-in Python type or something found
in the
neoalchemy.validators
module. - default – The default value for the property if not specified. This can be a callable. Either the value (or the return value if callable) must pass validation given by type.
- value – The starting value for the property. Must pass validation given by type.
- 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.
- primary_key (bool) – If set, the property is one of the object’s default bindings when :py:method::~neoalchemy.GraphObject.bind is called with no arguments.
- read_only (bool) – Not yet implemented.
-
value
¶ The current value of the property.
-
var
¶ The current Cypher variable for the property. A property must be bound to a
GraphObject
to compute its Cypher variable.
-
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
graph.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: -
schema
¶ A reference to the Graph’s
graph.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
¶ -
create
(node)¶ Create the schema for the Node.
Parameters: node (Node) – The Node instance to add to the schema Return type: None -
drop
(node)¶ Drop the schema for the Node.
Parameters: node (Node) – The Node instance to drop from the 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.
-