pythonsqlalchemy

Sqlalchemy get last X rows in order


I need to get the last X rows from a table, but in order of the ID. How could I achieve this?


Solution

  • query = users.select().order_by(users.c.id.desc()).limit(5)
    
    print reversed(conn.execute(query).fetchall() )
    

    something like that anyway