Problem with sqlite3 cursor and imbricated for loop
Gerhard Häring
gh at ghaering.de
Wed Nov 12 10:21:08 EST 2008
Steve Holden wrote:
> [...]
>> I feel with you. The fact that cursors, and not connection objects have
>> the executeXXX methods is totally braindead.
>>
> So you'd rather have to use separate connections? That would make
> isloated transaction processing a little tricky ...
No, I just find code like:
con = ...connect(...)
cursor1 = con.cursor()
cursor1.execute("select ...")
for row in cursor1:
cursor2 = con.cursor()
cursor2.execute("...)
quite verbose compared to:
con = ...connect()
for row in con.execute("select ...")
con.execute("...")
Both of which work with pysqlite (*).
Granted, the second form works way better with a reference-counting
garbage-collector like CPython has ;-)
>> That's why pysqlite (sqlite3) has alternative nonstandard executeXXX
>> methods in the connection object that return cursors.
>>
> It's also why SQLite's not a real RDBMS. Fortunately this doesn't stop
> it being very useful.
What does pysqlite extending the DB-API have to do with *SQLite* not
being a "real" RDBMS?
-- Gerhard
(*) And writing a wrapper for other modules that does the same is trivial.
More information about the Python-list
mailing list