Reputation: 3541
All, starting with neo4j and it's restclient and trying to send a cypher query to delete all nodes:
gdb = GraphDatabase("http://localhost:7474/db/data/")
query1 = """START n=node(*)
MATCH n-[r?]-()
WHERE ID(n) <> 0
DELETE n,r"""
gdb.query(q=query1)
query2 = """start r=node(*) return count(r)"""
print gdb.query(q=query2)[0]
Using the second query to count nodes indicates that the first query didn't run (properly at least). Note that query1 works fine in the neo4j data browser.
Any ideas here?
Upvotes: 0
Views: 601
Reputation: 4392
Your first query statement only builds a QuerySequence
object. Unless you require the result, e.g. by trying to access the result, or by calling get_response
, nothing is executed.
You can see that the nodes are actually deleted:
query1 = """START n=node(*)
MATCH n-[r?]-()
WHERE ID(n) <> 0
DELETE n,r
RETURN COUNT(n)"""
print gdb.query(query1).get_response()
# something like {u'columns': [u'COUNT(n)'], u'data': [[3]]}
Upvotes: 1