First of all, you have to create Neo4j class for connection:
class Neo4jConnection:
def __init__(self, uri, user, pwd):
self.__uri = uri
self.__user = user
self.__pwd = pwd
self.__driver = None
try:
self.__driver = GraphDatabase.driver(self.__uri, auth=(self.__user, self.__pwd))
except Exception as e:
print("Failed to create the driver:", e)
def close(self):
if self.__driver is not None:
self.__driver.close()
def query(self, query, parameters=None, db=None):
assert self.__driver is not None, "Driver not initialized!"
session = None
response = None
try:
session = self.__driver.session(database=db) if db is not None else self.__driver.session()
response = list(session.run(query, parameters))
except Exception as e:
print("Query failed:", e)
finally:
if session is not None:
session.close()
return response
After that create a connection:
uri = 'uri'
pwd = 'pwd'
user= 'user'
conn = Neo4jConnection(uri=uri, user=user , pwd=pwd)
And, you can run the below to delete all constraints:
## drop all constraints
const = conn.query("CALL db.constraints")
for c in const:
conn.query(f"DROP CONSTRAINT {c['name']}")
DROP GRAPH
; a scriptable lightweight server which can host a graph at any directory you point toneo4jlite --serve ./test-graph.db
; something else? Could you describe your particular testing setup? – YonderDROP GRAPH
but got a syntax error. In which Neo4J / CQL version is that supported? – GeerDROP GRAPH
would do it for me! right now I clear the database between test runs github.com/aj0strow/neo4j/blob/master/lib/neo4j.js#L57 – Geer