Skip to content Skip to sidebar Skip to footer

Database-independent Max() Function In Sqlalchemy

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?

Solution 1:

You can find aggregate functions in:

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

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

session.query(func.max(Table.column)) 

Post a Comment for "Database-independent Max() Function In Sqlalchemy"