From: Stuart B. <ze...@sh...> - 2002-01-21 05:32:14
|
On Monday, January 21, 2002, at 04:24 AM, Lars Kellogg-Stedman wrote: > Hello all, > > I've just started using pyPgSQL, and I've run into a frustrating > problem -- how do I determine the size of a result set *before* calling > one of the fetchxxx() functions? You don't. Most database systems behave this way as there is no way of telling how many rows will be returned without performing the query. As the query may take several hours, or even days, to actually complete this row count is only available after all rows have been fetched. > The rowcount attribute doesn't appear to be terribly useful. As far as > I can tell, it simply tells me the number of rows returned by the > previous fetchxxx() call -- a value which I can also get just by > calling len() on the return from fetchxxx(). Before a fetch call, > rowcount always contains -1. > > Is there any other way of getting at this information? If you *need* the rowcount, you can retrieve it by issuing a 'select count(blah) from ...' query first. -- Stuart Bishop <ze...@sh...> http://shangri-la.dropbear.id.au/ |