Skip to content

SQLAlchemy session.query(MyModel).all() equivalent in databases? #475

Answered by aminalaee
RodrigoTMOLima asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,
The short answer is no, you won't be able to do that in databases as this is not an ORM.

And as a side note I think that's not the recommended way in SQLAlchemy 1.4 onwards, it should be something like:

from sqlalchemy import select
stmt = select(Parent, Child).join(Parent.children).order_by(Parent.id)

with Session() as session:
    objects = session.query(stmt).scalars().all()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RodrigoTMOLima
Comment options

Answer selected by RodrigoTMOLima
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants