SQLAlchemy Core: order by desc
Sort column by asc/desc
desc = " " + asc_desc
order_by = re.sub('[^0-9a-zA-Z]+', '', order_by) + desc
query = query.order_by(text(order_by))
return query
From the SQLAlchemy docs:
from sqlalchemy import desc
stmt = select([users_table]).order_by(desc(users_table.c.name))
Or according to the same documentation link:
stmt = users_table.select().order_by(users_table.c.name.desc())