[DB-SIG] cursor.fetchiter()?

Anthony Baxter anthony at interlink.com.au
Wed Jun 22 15:08:00 CEST 2005

Would it make sense for DB-SIG compliant modules to support a 
cursor.fetchiter() type method, to use the iterator protocol
(instead of fetchall()'s current load-everything-into-memory
first approach). Clever extensions could be written to grab 
N at a time, where N is less than 10,000,000, but more than 1 -
this then means you get faster performance than fetchone(),
and a less sucky API.

res = cursor.fetchone()
while res:
    res = cursor.fetchone()


for res in cursor.fetchiter():

And yes, you can get something that's most of the way there 
now with something like the code in the cookbook entry
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/137270 - 
just wondering if it's something worth adding to the API. 

Anthony Baxter     <anthony at interlink.com.au>
It's never too late to have a happy childhood.

More information about the DB-SIG mailing list