The following excerpt should just work. (if i am not mistaken)
from py2neo import GraphService
gs = GraphService(address=address, user=user, password=password)
db = gs["neo4j"]
db.schema.create_uniqueness_constraint("Entity", "id")
Actual Behaviour
>>> db.schema.create_uniqueness_constraint("Entity", "id")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\claas\anaconda3\lib\site-packages\py2neo-5.0b1-py3.8.egg\py2neo\database.py", line 658, in create_uniqueness_constraint
self.graph.run(cypher).close()
AttributeError: 'GraphService' object has no attribute 'run'
The docs state this on the Schema object:
The schema resource attached to a Graph instance.
The object contained in Graph.schema.graph is a GraphService object and not a Graph object, hence the previous error.
A workaround is to replace the GraphService object in Schema.graph by the graph database object of the database that you want to create or delete constraints for/from.
from py2neo import GraphService
gs = GraphService(address=address, user=user, password=password)
db = gs["neo4j"]
db.schema.graph = db
db.schema.create_uniqueness_constraint("Entity", "id")
Steps to reproduce
The code blocks should suffice.
Thank you for py2neo. It has saved me countless hours of development!
Version Information
Expected Behaviour
The following excerpt should just work. (if i am not mistaken)
Actual Behaviour
The docs state this on the
Schema
object:The object contained in
Graph.schema.graph
is aGraphService
object and not aGraph
object, hence the previous error.I think that this is unintended.
Workaround
A workaround is to replace the
GraphService
object inSchema.graph
by the graph database object of the database that you want to create or delete constraints for/from.Steps to reproduce
The code blocks should suffice.
Thank you for
py2neo
. It has saved me countless hours of development!