My CREATE queries are not saving to the database.
I wrote some Python code using the official driver. I can step through the code and log the cypher, and even see the node returned to result has an id and a node in the debugger, but when I go to verify the nodes with MATCH in Neo4j Desktop, they're not there.
I tried to log the generated cypher, and when I paste the cypher from the log to Neo4j Desktop, they work - the nodes get created.
I can't for the life of me understand what I am doing wrong - I'm using code pasted from the offical docs. I tried with and without .consume()
and also tried the tx.write_transaction( ) method.
def create_some_node_with_related_node(self, name):
with self.driver.session() as session:
cypher = "MATCH (sn:SomeNode) " \
"WHERE sn.name=\"{name}\" " \
"CREATE (rn:RelatedNode{{propertyId:{property_id}, code:sn.code}})-[r:derivedFrom]->(sn) " \
"RETURN sn,r,rn".format(name=name, property_id=property_id)
neo.log(cypher, 101)
neo.incr('counter')
try:
result = session.run(cypher)
single = result.single()
return single[0]
except:
error = sys.exc_info()[0]
print('Error:', error)
return False
result is a <neo4j.work.summary.ResultSummary object at 0x7fc36de94d90>
and single is a <Node id=6257615 labels=frozenset({'RelatedNode'}) properties={'property_id': 8, 'code': 'X19235195'}>
But when I do MATCH(rn:RelatedNode) RETURN rn
in desktop after my script completes, there's nothing there.
Yet if I copy the generated cypher from my log, paste it into desktop and run it, it works fine, and the node & relationship are generated as expected.
What am I doing wrong?