Python SqlAlchemy order_by DateTime?
You can use like this
from sqlalchemy import desc
db.session.query(MyEntity).order_by(desc(MyEntity.time))
entities = MyEntity.query.order_by(MyEntity.my_date.desc()).limit(3).all()
should work.
You can do it like this:
entities = MyEntity.query.order_by(desc(MyEntity.time)).limit(3).all()
You might need to:
from sqlalchemy import desc
Here's some documentation.
Another option is this:
stmt = select([users_table]).order_by(users_table.c.name.desc())