[Python] How to query a pre-existing table in SQLAlchemy ORM?

Discussão em 'Python' iniciado por Stack, Junho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using SQLAlchemy to do some data processing and create some tables.

    I'm loading data from a table orm_table defined by the class ORMTable (which inherits from a Base class which itself inherits from a DeclarativeBase class), so I can query that table using session.query(ORMTable).all().

    However, I also need to query another table non_orm_table that already exists in the database and is not defined in the orm.

    How do I query this table from within the same session? I don't have a class associated with it so wondering what is the standard practice for such cases?

    Continue reading...

Compartilhe esta Página