Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session.run() method DOES NOT run a cypher statement within an auto-commit transaction. #195

Closed
erikyao opened this issue Nov 7, 2017 · 3 comments

Comments

@erikyao
Copy link

erikyao commented Nov 7, 2017

Hi neo4j-python-driver developers,

I was using BoltSession and found that its run() method just posts two messages, RUN and PULL-ALL, to its connection message queue, not exactly functioning as your document says:

Run a Cypher statement within an auto-commit transaction.

This is really misleading since I have a long query which may not finish before my script quits. It's better to revise your document and recommend other users to use the following practice:

with session.begin_transaction():
    tx.run("query")

Thanks!
Yao

@erikyao
Copy link
Author

erikyao commented Nov 7, 2017

Sorry I may have had some misunderstanding towards the term "auto-commit". It just states that there will be an automatically created transaction for the query involved and it will commit automatically too. It's not guaranteed that query will be executed immediately, is it?

I think a better statement would be:

Run a Cypher statement in auto-commit mode.

Thanks!

@zhenlineo
Copy link
Contributor

Hi @erikyao,

When you use session.run, two messages run and pull-all will be sent to the server. The moment the server receives these two messages, the server will automatically creates a transaction and run the cypher statement inside this transaction.

It is true that session.run will not ensure that your transaction is finished when run returns, while if you consume all your session run result or close your session, then it will be guaranteed to have your transaction finished. And it is highly recommended to always consume results and close sessions. You could also find more docs here

Cheers,
Zhen

@erikyao
Copy link
Author

erikyao commented Nov 7, 2017

Thanks, @zhenlineo! We have a long CREATE query so we didn't consume the result. We already learned the lesson.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants