SQLAlchemy ORDER BY DESCENDING?

前端 未结 6 1860
迷失自我
迷失自我 2020-11-27 09:21

How can I use ORDER BY descending in a SQLAlchemy query like the following?

This query works, but returns them in ascending order:



        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 10:00

    Just as an FYI, you can also specify those things as column attributes. For instance, I might have done:

    .order_by(model.Entry.amount.desc())
    

    This is handy since it avoids an import, and you can use it on other places such as in a relation definition, etc.

    For more information, you can refer this

提交回复
热议问题