SQLAlchemy session.query(MyModel).all() equivalent in databases? #475
-
Hello. I have the following tables in my database:
I am trying to get all instances of
However, when using the databases library, I seem to only have the option of using the
Instead, I get rows of joined data, such as:
Is there a way for me to do something similar to Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, 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() |
Beta Was this translation helpful? Give feedback.
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: