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

Automatic disconnection of native client #237

Closed
wlhjason opened this issue Jul 20, 2021 · 3 comments
Closed

Automatic disconnection of native client #237

wlhjason opened this issue Jul 20, 2021 · 3 comments

Comments

@wlhjason
Copy link

The DB API 2.0 Connection class implements the context manager protocol and closes each cursor upon exit (disconnects each underlying native client).

In contrast, the native Client class does not implement the context manager protocol and seems to expect users to call client.disconnect() when they are done.

Is there any particular reason for this design? If not, could I potentially open a PR to add __enter__ and __exit__ methods to the native Client (along with tests and docs)?

@xzkostyan
Copy link
Member

Hi.

There is no particular reason. __enter__ and __exit__ methods will make Client usage more convenient. Please add tests for this feature.

@wlhjason
Copy link
Author

@xzkostyan Just opened #238 to implement this.

@wlhjason
Copy link
Author

@xzkostyan Thanks for merging and tidying this up!

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