Open jasonnet opened 7 years ago
Howdy
I've previously had similar issues when ensuring uniqueness with py2neo, the follow code snippet in __init__.py
should see you right:
from .views import app
from .models import graph
def ensure_unique_constraint(graph, label, property_key):
if (property_key not in graph.schema.get_indexes(label)):
if property_key not in graph.schema.get_uniqueness_constraints(label):
graph.schema.create_uniqueness_constraint(label, property_key)
ensure_unique_constraint(graph, "User", "username")
ensure_unique_constraint(graph, "Tag", "name")
ensure_unique_constraint(graph, "Post", "id")
Thanks for the great tutorial. Starting it up, two of us here both experienced problems with uniqueness constraint conflicts. We were eventually able to work around this by commenting out the uniqueness constraint check, but we don't know what the proper fix is.
This occurred even on a freshly deleted (and created) database. In my case, the flask server was running in debug mode and neo4j was running on special localhost ports.
Here is the stack trace: