1

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 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

Yes use the Cypher based transactions for all your needs !
All correct. Py2neo only supports transactions when running Cypher directly. There currently exist a few Cypher builder classes that could help but this is an experimental feature and not very comprehensive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.