I'm wondering if this is part of the secret sauce: http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.join Also I guess cross-join may be another join type. JOIN is INNER by default.. https://stackoverflow.com/a/19646594/495157
On Friday, 9 February 2018 16:03:03 UTC, Jeremy Flowers wrote: > > I've got a domain model out of sqlacodegen. > I need to do a SQL a join between two tables, with no inferred > foreign-keys in the database I'm working on. > Consequently there isn't a relationship defined for the specific columns I > need to join > > 1) I need a INNER JOIN for the first. > 2) But later I need multiple LEFT JOINs on other tables, I've not yet > introduced to the code.. > > (1) How would I go about doing the INNER JOIN first?: (What is the > default? left, inner etc?) > > print(session.query(Jobmst.jobmst_type, > Jobmst.jobmst_name, > Jobmst.jobmst_prntname, > Jobmst.jobmst_prntid, > Jobmst.jobmst_evntoffset, > Jobmst.evntmst_id, > Jobdtl.jobdtl_proxy, > Jobdtl.jobdtl_proxy2, > Jobdtl.jobdtl_inhagent, > Jobdtl.jobdtl_inhevent, > Jobdtl.jobdtl_cmd, > Jobdtl.jobdtl_params, > Jobdtl.jobdtl_fromtm, > Jobdtl.jobdtl_untiltm, > Jobdtl.jobdtl_timewin, > Jobdtl.jobdtl_interval, > Jobdtl.jobdtl_intervalcnt > ).join(Jobdtl, Jobmst.jobmst_id==Jobdtl.jobdtl_id,) > .first()) > > > Why doesn't join have another parameter where I can say, 'inner', 'left', > etc? > Per the join types listed here: > https://www.w3schools.com/sql/sql_join.asp > > I've seen stuff here > > http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.join.params.isouter > And here... > > http://docs.sqlalchemy.org/en/latest/orm/loading_relationships.html#sqlalchemy.orm.joinedload > But if I understand it correctly I'd need a relationship defined for > joinedload. > > Can someone advise. Thanks > > -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.