Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Roger Binns wrote: > Yang Zhang wrote: >> Actually, this is only because Python 3 str is Python 2 unicode. Python >> 2 (which I'm currently using, and which I believe most of the world is >> using) str is a physical string of bytes, not a logical/decoded >> character string. Python 2.6

Re: [sqlite] Transaction isolation

2009-05-18 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yang Zhang wrote: > Actually, this is only because Python 3 str is Python 2 unicode. Python > 2 (which I'm currently using, and which I believe most of the world is > using) str is a physical string of bytes, not a logical/decoded > character

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Igor Tandetnik wrote: > Yang Zhang wrote: >> Pavel Ivanov wrote: >>> BTW, ACID that you mentioned has nothing to do with snapshot >>> isolation that you want to achieve. AFAIK only Oracle supports this >>> kind of statement isolation level. >> Actually, Oracle, Postgresql,

Re: [sqlite] Transaction isolation

2009-05-18 Thread Igor Tandetnik
Yang Zhang wrote: > Pavel Ivanov wrote: >> BTW, ACID that you mentioned has nothing to do with snapshot >> isolation that you want to achieve. AFAIK only Oracle supports this >> kind of statement isolation level. > > Actually, Oracle, Postgresql, SQL Server, Firebird, and

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Pavel Ivanov wrote: > BTW, ACID that you mentioned has nothing to do with snapshot isolation > that you want to achieve. AFAIK only Oracle supports this kind of > statement isolation level. Actually, Oracle, Postgresql, SQL Server, Firebird, and others support snapshot isolation.

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Roger Binns wrote: > Yang Zhang wrote: >> I copied and pasted this code straight from my actual application, which >> uses blobs instead of integers, which I need to convert into strings >> (since Python interfaces with blobs using the `buffer` type, not `str`). > > And for very good reason.

Re: [sqlite] Transaction isolation

2009-05-18 Thread John Elrick
D. Richard Hipp wrote: > On May 18, 2009, at 1:13 PM, John Elrick wrote: > > >> John Elrick wrote: >> >>> SNIP >>> >>> > I say this because your example implies that the Python wrapper > starts > the transaction automatically inside the execute, and I would not >

Re: [sqlite] Transaction isolation

2009-05-18 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yang Zhang wrote: > I copied and pasted this code straight from my actual application, which > uses blobs instead of integers, which I need to convert into strings > (since Python interfaces with blobs using the `buffer` type, not `str`). And for

Re: [sqlite] Transaction isolation

2009-05-18 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John Elrick wrote: > Are you certain the wrapper is behaving that way? The pysqlite wrapper (available as a sqlite3 Python module) by default parses your SQL and starts and ends transactions behind your back, in order to make it look like SQLite

Re: [sqlite] Transaction isolation

2009-05-18 Thread D. Richard Hipp
On May 18, 2009, at 1:13 PM, John Elrick wrote: > John Elrick wrote: >> SNIP >> I say this because your example implies that the Python wrapper starts the transaction automatically inside the execute, and I would not be surprised if it did so BEFORE executing the SQL

Re: [sqlite] Transaction isolation

2009-05-18 Thread John Elrick
John Elrick wrote: > SNIP > >>> I say this because your example implies that the Python wrapper starts >>> the transaction automatically inside the execute, and I would not be >>> surprised if it did so BEFORE executing the SQL parameter. >>> >>> >> The cursor() method that I call

Re: [sqlite] Transaction isolation

2009-05-18 Thread John Elrick
SNIP >> I say this because your example implies that the Python wrapper starts >> the transaction automatically inside the execute, and I would not be >> surprised if it did so BEFORE executing the SQL parameter. >> > > The cursor() method that I call on the conn for the SELECT should give

Re: [sqlite] Transaction isolation

2009-05-18 Thread Pavel Ivanov
SQLite doesn't support several simultaneous transactions on the same connection to database. So in fact your select and insert statements execute in the same transaction. And even more: your inserts are not committed until your select is completely finished. So for your task you should use

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Yang Zhang wrote: > John Elrick wrote: >> Yang Zhang wrote: >>> Roger Binns wrote: >>> Yang Zhang wrote: > for i in (str(row[0]) for row in conn.cursor().execute('SELECT key > FROM shelf ORDER BY ROWID')): > You are converting the key which is an integer

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
John Elrick wrote: > Yang Zhang wrote: >> Roger Binns wrote: >> >>> Yang Zhang wrote: >>> for i in (str(row[0]) for row in conn.cursor().execute('SELECT key FROM shelf ORDER BY ROWID')): >>> You are converting the key which is an integer into a string for no >>>

Re: [sqlite] Transaction isolation

2009-05-18 Thread John Elrick
Yang Zhang wrote: > Roger Binns wrote: > >> Yang Zhang wrote: >> >>> for i in (str(row[0]) for row in conn.cursor().execute('SELECT key FROM >>> shelf ORDER BY ROWID')): >>> >> You are converting the key which is an integer into a string for no >> apparent reason. >> > > I

Re: [sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Roger Binns wrote: > Yang Zhang wrote: >> for i in (str(row[0]) for row in conn.cursor().execute('SELECT key FROM >> shelf ORDER BY ROWID')): > > You are converting the key which is an integer into a string for no > apparent reason. I copied and pasted this code straight from my actual

Re: [sqlite] Transaction isolation

2009-05-18 Thread Igor Tandetnik
"Roger Binns" wrote in message news:4a1127e1.1040...@rogerbinns.com > If you also ask for the ROWID you will see that what is happening is a > new rowid is generated for the replaced row so that if you are > iterating over the table while modifying it then you effectively

Re: [sqlite] Transaction isolation

2009-05-18 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Yang Zhang wrote: > for i in (str(row[0]) for row in conn.cursor().execute('SELECT key FROM > shelf ORDER BY ROWID')): You are converting the key which is an integer into a string for no apparent reason. If you also ask for the ROWID you will see

[sqlite] Transaction isolation

2009-05-18 Thread Yang Zhang
Hi, for some reason the following program will loop forever: #!/usr/bin/env python import sqlite3 conn = sqlite3.connect(':memory:') conn.text_factory = bytes conn.execute('CREATE TABLE shelf (key INTEGER NOT NULL, value INTEGER NOT NULL)') for i in xrange(3): conn.execute('INSERT INTO