Skip to content
Advertisement

Trying to use SQLAlchemy relationships

As an example, I have a cities table and a movie theaters table. A city has multiple movie theaters so:

JavaScript

now i want to get all theaters for a city:

JavaScript

This query throws error:

JavaScript

not sure what I’m doing wrong?

Advertisement

Answer

Something like this should automatically do the join for you:

JavaScript

And then the query would be

JavaScript

Make sense?

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