sql >> Databasteknik >  >> RDS >> Mysql

Flera kopplingar med SQLAlchemy

Basera dina ytterligare anslutningar på de alias du har skapat:

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. Hur man använder IDENTITY()-funktionen i SQL Server

  2. Viloläge:Skapa index

  3. Åtkomst nekad för användaren 'root'@'localhost' (med lösenord:YES )

  4. Hur man lagrar data i databasen i LARAVEL 5.2