flypen
flypen

Reputation: 2585

How to use "compound order by" in sqlalchemy

Suppose there is a SQL statement:

select * from A order by cola

In sqlalchemy, we can use this code:

session.query(A).order_by(asc(cola))

Now I want to use a "compound order by" in SQL:

select * from A order by cola, colb

Then how will I translate it into sqlalchemy code? Can I use:

session.query(A).order_by(asc(cola, colb))

Probably I can't do it like this.

Upvotes: 10

Views: 7240

Answers (1)

flypen
flypen

Reputation: 2585

I find I can do this:

session.query(A).order_by('cola, colb')

Then this problem will be solved.

Upvotes: 11

Related Questions