How to do a simple subquery in SQLAlchemy

zerohedge

I'm a newbie in SQLAlchemy and haven't got much chance to deal with subqueries. I'm using Flask SQLAlchemy, for the record.

Below is the first part of the query:

Team.query.filter(Team.season_id==12610)

Below is the part I'd like to query the first part with: (If that is even possible)

Team.query.order_by(desc(Team.team_rank))

Basically, after filtering from a certain season_id, I want to to order the teams by team_rank.

Thanks in advance!

dizzyf

You're almost there! Just chain the commands.

from sqlalchemy import desc
Team.query.filter(Team.season_id == 12610).order_by(desc(Team.team_rank))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make a subquery in sqlalchemy

From Dev

Using SQLAlchemy, how do to PGSQL ranged window subquery?

From Dev

How to do scope with subquery

From Dev

How to do scope with subquery

From Dev

How to convert SQL scalar subquery to SQLAlchemy expression

From Dev

How to make a subquery in Sqlalchemy using not in with two fields?

From Java

How to do this in Laravel, subquery where in

From Dev

How to do this in Laravel, subquery with join

From Dev

How to do Laravel ORM subquery

From Dev

How to do subquery in CakePHP 3

From Dev

How to do this in Laravel, subquery where not in

From Dev

How to use a subquery to filter a sqlalchemy query on a one to many relationship?

From Dev

SQLAlchemy - subquery in in_ clause

From Dev

SQLAlchemy Joining with subquery issue

From Dev

Subquery in order by in sqlalchemy

From Dev

Sqlalchemy in_ subquery

From Dev

Limiting the subquery with SQLAlchemy

From Dev

SQLAlchemy - subquery in in_ clause

From Dev

Calculate avg in subquery in SQLAlchemy

From Dev

SQLAlchemy class method for subquery

From Dev

How do I access a field inside a subquery within a subquery?

From Dev

How to do a subquery on the same table in Hibernate?

From Dev

How to do a subquery in group_concat

From Dev

How to do Subquery for same Table in Laravel Eloquent

From Dev

How to do an IN with a subquery returning 2 columns?

From Dev

How do I subquery the right results

From Dev

How can I do this in SQLAlchemy?

From Dev

Simple Example Subquery Linq

From Dev

Can I have SQLAlchemy do subquery eager loading without repeating the full original query?