max() with SQLAlchemy 0.4.7

36 views
Skip to first unread message

Jakob L.

unread,
Oct 11, 2011, 10:45:02 AM10/11/11
to sqlal...@googlegroups.com
Sorry if this has already been posted but couldn't find any docs for 0.4 nor any examples where columns aren't used in the query. 

As I understand, you can't use columns in queries in 0.4. 

So how should I write: 
session.query(Media.id, func.max(Media.sort_order)).first()


Michael Bayer

unread,
Oct 11, 2011, 11:10:06 AM10/11/11
to sqlal...@googlegroups.com
you'd use a select() construct in conjunction with Session.execute().

the current tutorial is mostly the same for 0.4:



--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/Tlll3oOFkDgJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Jakob L.

unread,
Oct 11, 2011, 11:56:19 AM10/11/11
to sqlal...@googlegroups.com
select([func.max(Media.c.sort_order)])   works great! 

Thanx!

//J
Reply all
Reply to author
Forward
0 new messages