-
Notifications
You must be signed in to change notification settings - Fork 189
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
Introduce driver.execute_query #833
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥇
(Just minor comments)
docs/source/api.rst
Outdated
:returns: the result of the ``result_transformer`` | ||
:rtype: T | ||
|
||
.. versionadded:: 5.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docs/source/api.rst
Outdated
:members: session, query_bookmark_manager, encrypted, close, | ||
verify_connectivity, get_server_info | ||
|
||
.. method:: execute_query(query, parameters=None,routing=neo4j.RoutingControl.WRITERS, database=None, impersonated_user=None, bookmark_manager=self.query_bookmark_manager, result_transformer=Result.to_eager_result, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a :raises:
field? Or does it raise too many different exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are plenty of errors this can raise. Here are the one's I can think of on the spot
Neo4jError
(or any sub-class) - anything the server complains aboutSessionExpired
,ServiceUnavailable
(or any sub-class) - lost/couldn't establish connectivity (after the retries this API includes)ConfigurationError
TypeError
ValueError
(maybe evenIndexError
?) - invalid configuration/parameters or trying to use a feature that's too new for the server you're connected toBoltError
(or any sub-class; internal error class you shouldn't ever encounter) - the server violated the protocol
There might be more that I can't think of right now. My conclusion:
- All of there errors are fatal (there is pretty much no benefit in giving them different treatment). The user might as well just catch any exception, maybe log it or whatever they feel doing, and then give up (that could mean crash, surface some error to the end-user, whatever is suitable). Plus maybe fixing their code afterwards.
- I can hardly give any guarantees what errors this method can raise as it pretty much exercises the whole stack of the driver. It's highly likely that I'll forget some corner of the driver and, even if not, that this piece of documentation will unsync sooner or later as it's so far up the abstraction stack.
So much for why I didn't include it. If you think it'd be helpful nonetheless, we can make it happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user might as well just catch any exception
👍
a2b80f1
to
7ff6803
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌵 🌵 🌵
Depending on
Driver.execute_query
neo4j-drivers/testkit#531