2005/12/17, limodou <[EMAIL PROTECTED]>:
> 2005/12/17, Robert Leftwich <[EMAIL PROTECTED]>:
> > limodou wrote:
> >
> > >Sometimes I just want to count the number of records which match the
> > >condition, I want to know is there a count function? Or think about to
> > >implement one?
> > >
> > >
> > From the doco
> > (http://sqlalchemy.org/docs/sqlconstruction.html#sql_select_functions):
> >
> > select([func.count(users.c.user_id)]).execute()
> >
> > which results in :
> >
> > SELECT count(users.user_id) FROM users
> >
I tried that, but I feel that is not very convenience, you should:
r = select([func.count(users.c.user_id)]).execute()
print r.fetchone()[0]
If there is a count() method, just like:
number = count([user]).execute()
or number = select([user]).execute().count()
or somethins else
May be more helpful. So that you don't need to invoke fetchone() again.
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users