[egenix-users] No commit in connection context mgr
jan.murre at catalyz.nl
Tue Nov 8 17:09:24 CET 2016
I am using the following code with a MS SQL database and the Microsoft
con = Connect(dsn, user=user,
with con.cursor() as cursor:
cursor.callproc('proc_AddReservation_web', (12, None, 'nl-nl'))
result = 
if not cursor.nextset():
Based on the documentation I would have expected a commit inside the
When I use a conn.commit() or even a cursor.close() in the inner with block
(the cursor context manager), the transactions gets committed.
Setting clear_auto_commit=0 results in the following exception:
"mx.ODBC.Error.NotSupportedError: connection has AUTOCOMMIT turned on"
So, it seems one of the context mgr. does try to commit the transaction.
Furthermore, I want to add a try except block around the two context mgrs
to catch/log/reraise exceptions.
However, it seems that the context managers effectively swallow exceptions
and do not reraise them on __exit__.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the egenix-users