sql >> Database >  >> RDS >> Mysql

Meerdere joins met SQLAlchemy

Baseer je verdere joins op de aliassen die je hebt gemaakt:

Distributor.query\
    .outerjoin(alias_commercial_address, Distributor.commercial_address)\
    .outerjoin(alias_commercial_address_country, alias_commercial_address.country)\
    .outerjoin(alias_invoice_address, Distributor.invoice_address)\
    .outerjoin(alias_invoice_address_country, alias_invoice_address.country)\
    .options(contains_eager(Distributor.commercial_address, alias=alias_commercial_address)
             .contains_eager(alias_commercial_address.country, alias=alias_commercial_address_country),
             contains_eager(Distributor.invoice_address, alias=alias_invoice_address)
             .contains_eager(alias_invoice_address.country, alias=alias_invoice_address_country))\
    .all()



  1. C# Mysql-verbinding in txt-bestandsconfiguratie

  2. Efficiënte manier om verbinding te maken met een database wanneer meerdere functies query's uitvoeren

  3. Inspecteer de besturingsbron van alle besturingselementen in uw MS Access-project

  4. SQLAlchemy - SQLite voor testen en Postgresql voor ontwikkeling - Hoe overzetten?