Thread: Re: [SQLObject] Does SQLObject have a queryAll-like method which returns the result as generator?
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: masayuki.takagi <kam...@gm...> - 2008-03-21 09:58:38
|
>> 2. queryAll fetches the results by calling DB API cursor.fetchall >> (). To >> make queryAll a generator one must rewrite the method to at least >> to use >> cursor.fetchmany(). > > I will accept patches for the trunk. i have tried MySQLdb.cursors.SSCursor instead of the default Cursor that SQLObject use, and i can fetch the results row by row. i will try to use cursur.fetchmany() too. -- masayuki takagi |
From: masayuki.takagi <kam...@gm...> - 2008-03-21 11:19:04
|
On Mon, 17 Mar 2008 15:55:03 +0300, Oleg Broytmann wrote: > On Mon, Mar 17, 2008 at 03:51:47PM +0300, Oleg Broytmann wrote: >> BTW, SelectResults (i.e., the result of calling .select()) has >> .lazyIter() method that returns an iterator that inside its .next >> () method >> calls cursor.fetchone() instead of .fetchall(). So you can try >> >> for row in MyTable.select(condition).lazyIter(): >> process(row) > > The problem with this approach is that all fetched rows are put > into > SQLObject's cache, so that process() must clear the cache from time to > time: > > MyTable._connection.cache.clear() > I think that cursor objects has all result sets as list in it even when i use cursor.fetchone(). So it would be still the cause of swapping out. -- masayuki takagi |
From: Oleg B. <ph...@ph...> - 2008-03-21 11:22:33
|
On Fri, Mar 21, 2008 at 08:18:54PM +0900, masayuki.takagi wrote: > I think that cursor objects has all result sets as list in it even > when i use cursor.fetchone(). > So it would be still the cause of swapping out. AFAIR it's a problem in MySQLdb, other DB API drivers do fetch properly. Oleg. -- Oleg Broytmann http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |