On Dec 17, 2005, at 12:05 AM, limodou wrote:

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 would vote for a "count" function on the base class for Selectable, which is any table, join, alias, select statement, union, etc.

so when you do:

        x = mytable.count()

it compiles to:

        x = select([count(1)], from_obj=[mytable]).scalar()

when you do:

        x = mytable.count(mytable.c.col1==7)

it compiles to:

        x = select([count(1)], mytable.c.col1==7).scalar()

the question is, do we want to put these functions at the ORM level as well:

        x = User.mapper.count(User.c.user_name=='fred')

        x = User.mapper.count_by(user_name='fred')




-------------------------------------------------------
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_id=7637&alloc_id=16865&op=click
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to