Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
#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

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Ryan Kelly
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 __

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
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")

Re: sqlite savepoint problem [solved]

2010-03-15 Thread Laszlo Nagy
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

Re: sqlite savepoint problem

2010-03-14 Thread Ryan Kelly
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

Re: sqlite savepoint problem

2010-03-14 Thread Ryan Kelly
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

Re: sqlite savepoint problem

2010-03-14 Thread Laszlo Nagy
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

Re: sqlite savepoint problem

2010-03-14 Thread Laszlo Nagy
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

Re: sqlite savepoint problem (was: Re: sqlite3 is sqlite 2?)

2010-03-14 Thread Ryan Kelly
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

sqlite savepoint problem (was: Re: sqlite3 is sqlite 2?)

2010-03-14 Thread Laszlo Nagy
That's the sqlite *bindings* version: >>> sqlite3.version '2.4.1' >>> sqlite3.sqlite_version '3.6.16' >>> Thanks. I tried it and RELEASE command didn't work: >>> import sqlite3 >>> conn = sqlite3.connect(':memory:') >>> with conn: ... conn.execute("BEGIN") ... conn.execute("