How to use "complex order" in sqlalchemy

Suppose there is an 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 "compound order" in SQL:

 select * from A order by cola, colb 

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

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

Maybe I can't do it like this.

+7
source share
1 answer

I find that I can do this:

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

Then this problem will be solved.

+8
source

All Articles