Does MySQLdb rollback on control-C? Maybe not.
mrmakent at cox.net
Fri Sep 3 21:41:39 CEST 2010
On Sep 3, 12:22 am, John Nagle <na... at animats.com> wrote:
> I would expect MySQLdb to rollback on a control-C, but it doesn't
> seem to have done so.
> Something is broken.
I wouldn't expect it to, I'd expect to roll back on an exception, or
commit if not. Perhaps this will help you. I use it in production
# This is a transaction context manager. It will ensure that the code
# the context block will be executed inside a transaction. If any
# occurs, the transaction will be rolled back, and the exception
# If no exception occurs, the transaction will be committed.
# db is a database connection object.
from contextlib import contextmanager
More information about the Python-list