To get custom columns from a query you can use the with_entities() method to restrict which columns you'd like to return in the result. Use label() method to give AS value to your query. To use functions, look up func the function generator. Documentation link: docs.sqlalchemy.org
Source code viewer
result = db\ .query(SomeModel)\ .with_entities( SomeModel.column_1.label('c1'), SomeModel.column_2.label('c2') )Programming Language: Python