Let\'s say I have a User
model with fields popularity
and date_created
. I want to do the following query:
SELECT * FROM us
What you also could do:
from sqlalchemy import and_, or_
User.query.order_by(and_(User.popularity.desc(), User.date_created.desc())).all()
Note: and_
and or_
are coming from the sqlalchemy library and not from flask_sqlalchemy library.
sqlalchemy is a dependency for flask_sqlalchemy, so you should be good.
LTS: You can mix sqlalchemy lib with flask_alchemy lib