#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 h
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 __
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")
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 isola
On Fri, 2010-03-12 at 08:32 +0100, Laszlo Nagy wrote:
> > From memory you can't issue a "CREATE TABLE" statement inside a
> > transaction, at least not at the default isolation level. Such a
> > statement will automatically commit the current transaction. Doesn't
> > help with your current proble
On Fri, 2010-03-12 at 08:48 +0100, Laszlo Nagy wrote:
> >
> > I'm now confused. Also, I could not find anything about these
> > isolation levels on the sqlite website. The only think I could find is
> > "PRAGMA read_uncommited". If that is the same as setting
> > isolation_level to None, then I
I'm now confused. Also, I could not find anything about these
isolation levels on the sqlite website. The only think I could find is
"PRAGMA read_uncommited". If that is the same as setting
isolation_level to None, then I don't want it.
Yes, it is. Here is a test:
import os
import sqlite3
From memory you can't issue a "CREATE TABLE" statement inside a
transaction, at least not at the default isolation level. Such a
statement will automatically commit the current transaction. Doesn't
help with your current problem but worth pointing out :-)
Thank you. I'll keep in mind.
Whe
On Fri, 2010-03-12 at 07:46 +0100, Laszlo Nagy wrote:
> >
> >>> import sqlite3
> >>> conn = sqlite3.connect(':memory:')
> >>> with conn:
> ... conn.execute("BEGIN")
> ... conn.execute("create table a ( i integer)")
> ... conn.execute("insert into a values (1)")
> ... conn.execute