How do I join different tables in a sqlalchemy query with the same column names?
Description of tables:
License: id, customer_id, product_id, expires_at
Customer: id, name
Product: id, name
I'm asking:
result = session.\
query(License.id, License.customer_id, License.product_id, License.status, License.expires_at,\
Customer.name,\
Product.name).\
# some filtering on those columns (JOIN conditions)
all()
I want the concatenated table to contain:
License.id, Customer.name, Product.name
Now result
I am getting the list KeyedTuples
. How can I access the required columns? eg result[0].name
gives only Customer.name
, how to get Product.name
also?
+3
source to share