On Monday, April 3, 2017 at 7:09:41 PM UTC-4, Jason T. wrote:
>
> I think there may be even a cleaner way to do this since I have
> relationships() built into the models,
>
In that case, you will need to use "contains_eager" if you play on
iterating on any of the relationships
Yes, I had read the documentation. I am just new to SQL and databases in
general. I think there may be even a cleaner way to do this since I have
relationships() built into the models, but since the tables have multiple
foreign keys I think I had to specify the "on clause" anyhow. Thanks for
Have you read the tutorial at
http://docs.sqlalchemy.org/en/rel_1_1/orm/tutorial.html#querying-with-joins
and read all the examples at
http://docs.sqlalchemy.org/en/rel_1_1/orm/query.html#sqlalchemy.orm.query.Query.join?
There's nothing odd about the joins you're trying to build here.
Okay. I figured out how to use the ORM without joins, but I still can't
figure out how to use the joins. :(
bus1_alias = aliased(sam.Bus)
bus2_alias = aliased(sam.Bus)
branch_db = self.db_hook.session.query(sam.Branch). \
filter(sam.Branch.id_model == sam.Bus.id_model). \