On 7/12/06, Kevin Dangoor <[EMAIL PROTECTED]> wrote:
I'm writing a section about migrating a database from SQLObject to
SQLAlchemy. I think I've found a minor usability wart: in SQLObject,
you can do "SomeClass.select().count()". In SQLAlchemy with
ActiveMapper, the equivalent is "list( Page.table.count().execute())[0]
[0]", which is a little painful. (Straight up SQLAlchemy without
ActiveMapper still seems a bit cumbersome, because Page.table is just
replaced by "page" or whatever table instance you might have defined...)

Am I missing some shortcut, or is this really the way to do this?

Glancing at the source, it looks like it you could add a method to ActiveMapperMeta like

def count(cls):
  return cls.table.count().scalar()

add *args etc if desired...

--
Jonathan Ellis
http://spyced.blogspot.com
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users

Reply via email to