You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| You can also get all the rows immediately by filling in a list:
|
| rows=list( cursor.execute("select * from example") )
| for row in rows:
| cursor.execute("insert ...")
|
| This last approach is recommended since you don’t have to worry
| about the database changing while doing the select.
From this I understand that changing the database (even if using a
different cursor) may mess with the result set of the running query.
However, when I tried to test this behaviour (try attached testcase) it
seems that the result set is not affected.
Unfortunately I also could not find any information about the expected
behavior in this situation on the SQLite website.
Do you have any information on which behaviour I can rely on? I would
rather avoid having te fetch the entire result set into a list, both for
performance and style reasons.
The specific example I was thinking of was someone who posted to the SQLite mailing
list who was doing 'select * from example order by rowid' and then for each row
returned was doing an update that actually turned into a replace (thereby allocating
a new rowid) on that row. He essentially got an infinite number of results.
You can see the discussion at http://www.mail-archive.com/sqlite-users@sqlite.org/msg42660.html In summary there are two important things about SQLite. The first is that it does
not get the next row of results until you ask for them, calculating them on the fly.
The second is that changes/transactions on the same connection are not isolated from
each other.
From Nikolaus@rath.org on June 08, 2009 11:20:52
In http://apsw.googlecode.com/svn/publish/cursor.html it says that the
preferred way to do changes to a database is this one:
| You can also get all the rows immediately by filling in a list:
|
| rows=list( cursor.execute("select * from example") )
| for row in rows:
| cursor.execute("insert ...")
|
| This last approach is recommended since you don’t have to worry
| about the database changing while doing the select.
From this I understand that changing the database (even if using a
different cursor) may mess with the result set of the running query.
However, when I tried to test this behaviour (try attached testcase) it
seems that the result set is not affected.
Unfortunately I also could not find any information about the expected
behavior in this situation on the SQLite website.
Do you have any information on which behaviour I can rely on? I would
rather avoid having te fetch the entire result set into a list, both for
performance and style reasons.
Attachment: 05_apsw.py
Original issue: http://code.google.com/p/apsw/issues/detail?id=48
The text was updated successfully, but these errors were encountered: