We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is it possible (or sensible) to use the context handler for the connection, e.g.:
connection = pymysql.connect(host='localhost', user='user', password='passwd', db='db', charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor) with connection as cursor: ... # do something # proceed
Precisely: Is the connection closed after the with-block? I ask, because
def __exit__(self, exc, value, traceback): """On successful exit, commit. On exception, rollback""" if exc: self.rollback() else: self.commit()
and not
def __exit__(self, exc, value, traceback): """On successful exit, commit. On exception, rollback""" if exc: self.rollback() else: self.commit() self.close()
The text was updated successfully, but these errors were encountered:
Is it possible (or sensible) to use the context handler for the connection
No. DB-API 2.0 doesn't define context manager API.
Precisely: Is the connection closed after the with-block?
No, as you can see.
Currently, connection's contextmanager is for managing transaction. For compatibility with MySQL-python, I can't change the behavior easily.
Sorry, something went wrong.
No branches or pull requests
Is it possible (or sensible) to use the context handler for the connection, e.g.:
Precisely: Is the connection closed after the with-block? I ask, because
and not
The text was updated successfully, but these errors were encountered: