开发者

Database-Independent MAX() Function in SQLAlchemy

开发者 https://www.devze.com 2022-12-21 09:59 出处:网络
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? You can find aggregate functions in:

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?


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)) 
0

精彩评论

暂无评论...
验证码 换一张
取 消