Skip to content
Advertisement

Querying association table object directly

I have to query the relationships directly, since I have to display them seperatly.

How do I do this in SQLAlchemy? When I try this:

It causes this error:

Advertisement

Answer

the usage you have above is creating a join() construct, which is a Core (non-ORM) construct representing a join() of two tables (but not a full blown select()).

when using the ORM you usually start off a SELECT using the Query object. Querying from the class itself is a pattern offered by extensions like flask-sqlalchemy, but these extensions are usually confusing in this regard. Given any class or table you can query against it using the Query object:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement