views:

57

answers:

1

I'd like to calculate a MAX() value for a column. What's the proper way to do this in sqlalchemy while preserving database independence?

+2  A: 

You can find aggregate functions in:

from sqlalchemy import func 
func.avg(...) 
func.sum(...) 
func.max(...) 

In 0.5 you can use an ORM query like a select:

session.query(func.max(Table.column)) 
Dave
Is this database independent?
ensnare
I believe it is :)
Dave
This was great. Thank you, Dave.
ensnare