Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-19 Thread jhermann
c.execute("select * from stocks") for s in list(c): print s[0] c.execute("select * from stocks where price<20") for sp in c: print ' '+sp[0] c.close() The simple addition of list() should do away with the dependency on mysql's implementation, since it forces the instant fetch of al

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-13 Thread Steve Holden
Gerhard Häring wrote: > Steve Holden wrote: [...] >>> >> 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? > Nothing at all. I was just being pissy. Sorry

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Gerhard Häring
Charles V. wrote: Hi, Both may be standard compliant, but if you're depending on implementation details, you may still get different behaviour. I'm pretty sure that MySQLdb always fetches the entire resultset from the server. The sqlite3 module uses what would have been called "server-side curs

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Gerhard Häring
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

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Charles V.
Hi, > Both may be standard compliant, but if you're depending on > implementation details, you may still get different behaviour. > I'm pretty sure that MySQLdb always fetches the entire resultset from > the server. The sqlite3 module uses what would have been called > "server-side cursors" in rea

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Steve Holden
Gerhard Häring wrote: > Charles V. wrote: >> Hi, >> >> Thank for replying. >> >>> Either use a second cursor OR ensure you fetch all the data from the >>> first .execute() first: >> >> Are these really the only solutions ? > > Yes. > >> I was expecting the same behavior than MySQLdb module, whic

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Steve Holden
Charles V. wrote: > Hi, > > Thank for replying. > >> Either use a second cursor OR ensure you fetch all the data from the >> first .execute() first: > > Are these really the only solutions ? I was expecting the same behavior than > MySQLdb module, which is, as sqlite3, DB-API 2.0 compatible. >

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Gerhard Häring
Charles V. wrote: Hi, Thank for replying. Either use a second cursor OR ensure you fetch all the data from the first .execute() first: Are these really the only solutions ? Yes. I was expecting the same behavior than MySQLdb module, which is, as sqlite3, DB-API 2.0 compatible. Both ma

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-12 Thread Charles V.
Hi, Thank for replying. > Either use a second cursor OR ensure you fetch all the data from the > first .execute() first: Are these really the only solutions ? I was expecting the same behavior than MySQLdb module, which is, as sqlite3, DB-API 2.0 compatible. It means a program written for MySQ

Re: Problem with sqlite3 cursor and imbricated for loop

2008-11-11 Thread Michiel Overtoom
Charles V. wrote: It seems the second call to execute modify the first cursor. Is it normal ? How am I suppose to write this ? Maybe introduce a second cursor? import sqlite3 conn = sqlite3.connect(':memory:') c = conn.cursor() d = conn.cursor() # second cursor c.execute('''create table stock

Problem with sqlite3 cursor and imbricated for loop

2008-11-11 Thread Charles V.
Hi, I hope this is not already known. But Google wasn't any help. So here begins a script to explain my problem. - import sqlite3 conn = sqlite3.connect(':memory:') c = conn.cursor() c.execute('''create table stocks (date text, trans text, symbol text, qty real, price re