How do I query the association table in SQLAlchemy?

I would like to retrieve only key pairs stored in the association table in SQLAlchemy. One way is to create an association class and do something like session.query(Assoc).all()

.

Can you query the mapping table in a similar way?

+3


source to share


1 answer


Tables can be queried in the same way as declarative models. The request returns a list of keys, not instances of the class.



session.query(my_table).all()

      

+3


source







All Articles