[openstack-dev] [Neutron] need help in translating sql query to sqlalchemy query

Venkata Anil vkommadi at redhat.com
Tue Dec 1 11:15:08 UTC 2015


Hi All

I have the below sql query which - "lists routers connected to given 
internal and external networks"

select DISTINCT routerports.router_id from routerports inner join ports 
as ports1 on (ports1.id=routerports.port_id and 
ports1.network_id=internal_network_id) inner join ports as ports2 on 
(ports2.device_id=routerports.router_id and 
ports2.network_id=external_network_id);

In the above query I am joining port table to routerport table twice.

Can someone help me in translating that to SQLAlchemy query?
This is required for the change 
https://review.openstack.org/#/c/220135/2/neutron/db/l3_db.py
(see review comments)

Thanks
Anil Venkata





More information about the OpenStack-dev mailing list