-
Notifications
You must be signed in to change notification settings - Fork 442
Remove context interface from Connector #295
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
Conversation
Guys, sorry for writing into this closed ticket, but what was the reasoning behind the removal of such an important functionality? |
What do you expect the context interface do? |
Short background: I've always used Postgresql, mostly with psycopg2, which has similar contextmanager functionality. My confusion was that while in this pull request #295 (Dec 2018) you deleted enter and exit methods of the connection, in the recent (10 days ago) PR #413 it's back again, albeit in a much shorter form. That's why I was confused, what was the reason to remove it and why is it now okay to put it back? |
What do you expect the context interface do? |
From what I can see the old code was quite useful - it provided a contextmanager which was creating a cursor instance, plus doing a commit or rollback in exit. To answer your questions: This is what I would expect from such a ctx manager. Yes, I read the code. Yes, it seems like it did what I expected. |
Hm, it seems psycopg2 behavior is the same to old
That's why I change the behavior of the And I removed the |
I agree, with some of the comments in your links that I would like a contextmanager of a connection to returns a connection, and for cursor return a cursor, not to combine these things in one entity. So I can have extra control when I want to apply .commit() manually, for example. |
While I agree that your changes make sense, you are making the behavior of mysqlclient-python inconsistent with not only psycopg2, but with the standard library sqlite3 as well. https://docs.python.org/3.8/library/sqlite3.html#using-the-connection-as-a-context-manager Some people probably expected a different behavior, but are you sure that there aren't more of them who expect it to behave the way the rest of the world does? |
This reverts commit c64915b.
No description provided.