Skip to content

Add context manager to Connection. #886

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

Merged
merged 1 commit into from
Jan 2, 2021
Merged

Add context manager to Connection. #886

merged 1 commit into from
Jan 2, 2021

Conversation

cmauro1
Copy link
Contributor

@cmauro1 cmauro1 commented Aug 17, 2020

Fixes #735.

Added __enter__ and __exit__ methods (lines 329 - 334) to allow for with statement
@j08lue
Copy link

j08lue commented Sep 9, 2020

Why was the context manager functionality removed in the first place? Would you prefer a different way to use contexts with connection objects?

@methane
Copy link
Member

methane commented Sep 9, 2020

See #735.

@methane methane changed the title Update connections.py Add context manager to Connection. Sep 9, 2020
@methane
Copy link
Member

methane commented Sep 9, 2020

I will merge this before releasing 1.0.
But current master branch is for 0.10.

@j08lue
Copy link

j08lue commented Sep 9, 2020

I see, thank you.

@methane methane merged commit 4e481fa into PyMySQL:master Jan 2, 2021
@methane methane mentioned this pull request Jan 6, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

With + Connection - returns cursor rather than the connection, doesn't close connection on exit
3 participants