[DB-SIG] DB API extension suggestion
Michael Kleehammer
mkleehammer at gmail.com
Thu Jun 21 21:48:35 CEST 2007
I'm not sure if there is a need for context support at the moment.
Almost all databases automatically rollback transactions if they are
not committed before a connection is closed. In the pyodbc connection
finalizer, I automatically issue a rollback if a commit didn't occur.
Since CPython uses reference counting (and will for the foreseeable
future), this allows you to just use the following:
def function():
cnxn = get_connection()
cursor = connection.cursor()
cursor.execute("update ...")
cursor.execute("delete from ...")
cursor.commit()
If an exception is raised before the commit, everything is rolled back.
+0
Michael Kleehammer
pyodbc maintainer
http://pyodbc.sourceforge.net
More information about the DB-SIG
mailing list