如何descending在如下所示的SQLAlchemy查询中使用ORDER BY ?
descending
此查询有效,但以升序返回:
query = (model.Session.query(model.Entry) .join(model.ClassificationItem) .join(model.EnumerationValue) .filter_by(id=c.row.id) .order_by(model.Entry.amount) # This row :) )
如果我尝试:
.order_by(desc(model.Entry.amount))
然后我得到:NameError: global name 'desc' is not defined。
NameError: global name 'desc' is not defined
from sqlalchemy import desc someselect.order_by(desc(table1.mycol))
来自@ jpmc26的用法