No it doesn't. The problem is that using a connection as a context
manager doesn't do what you think.
It does *not* start a new transaction on __enter__ and commit it on
__exit__. As far as I can tell it does nothing on __enter__ and calls
con.commit() or con.rollback() on exit. With
Annotating your example:
# entering this context actually does nothing
with conn:
# a transaction is magically created before this statement
conn.execute(insert into a values (1))
# and is implicitly committed before this statement
conn.execute(SAVEPOINT sp1)
On Fri, 2010-03-12 at 09:35 +0100, Laszlo Nagy wrote:
No it doesn't. The problem is that using a connection as a context
manager doesn't do what you think.
It does *not* start a new transaction on __enter__ and commit it on
__exit__. As far as I can tell it does nothing on __enter__
#1. By using isolation_level = None, connection objects (used as a
context manager) WON'T automatically commit or rollback transactions.
#2. Using any isolation level, connection objects WON'T automatically
begin a transaction.
#3. Possibly, include your connection manager class code, to show