Database Independent MAX () Function in SQLAlchemy

I would like to calculate the MAX () value for a column. What is the correct way to do this in sqlalchemy while maintaining database independence?

+3
source share
1 answer

You can find aggregate functions in:

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

At 0.5, you can use an ORM query, for example select:

session.query(func.max(Table.column)) 
+5
source

Source: https://habr.com/ru/post/1734937/


All Articles