[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Stephen Emslie
Well, I would have expected ResultProxy.rowcount to do just that (return the number of rows in the last executed statement) but I just get 0 from it. Perhaps someone could explain how to use it correctly. Stephen Emslie On Thu, Mar 12, 2009 at 5:20 PM, jeff jeffre...@gmail.com wrote: hi.

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Michael Bayer
database cursors are essentially iterators so a total rowcount, without fetching all the rows, is not available in a platform-agnostic way. the usual strategy to find out how many rows of something exist in the DB is to do SELECT COUNT(*). Stephen Emslie wrote: Well, I would have expected

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread jeff
thanks i will use select count (*) i was making a leap that there would be something in pgdb which allows a function like: sql_txt = select * from addresses cursor.execute(sql_txt) rows=cursor.fetchall() rows_returned = cursor_result.rowcount where the rowcount property contains the number of

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread Mike Conley
If you use rows = cursor.fetchall() you have already executed the query and the result is a list of RowProxy's returned by the query. Count then is simply count = len(rows) Otherwise, the count(*) approach is correct. -- Mike Conley On Fri, Mar 13, 2009 at 4:42 PM, jeff

[sqlalchemy] Re: getting the number of records in a result set from select

2009-03-13 Thread jeff
thank you that got me where i was trying to get. originally in the first example i was not adding the fetchall(). len() and rowcount were not yielding anything in that case. then once fetchall() was added i used len() as suggested and it worked. thanks. On Mar 13, 9:30 pm, Mike Conley