Adding a node in a transaction using py2neo

674 views Asked by At

I have code that uses py2neo to create and insert a node into the node4j database.

However, I need to do this in a transaction.

graph.create(node) creates and commits the node.

I get a transaction by tx = graph.cypher.begin()

The documentation says Transaction accepts a statement. I don't have a statement, I have a Node instance.

Is there any way to convert a Node instance to a statement, or do I need to retool my code to create nodes using Cypher statements?

Or, does py2neo implement transactions some other way?

1

There are 1 answers

2
betseyb On

It's pretty clear from the docs that Transactions are only available for Cypher statements in py2neo, since transactions are only mentioned under the Cypher API.

See http://py2neo.org/2.0/intro.html#cypher