Reputation: 4926
Description of the tables are:
License: id, customer_id, product_id, expires_at
Customer: id, name
Product: id, name
I am querying like this:
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 joined table to contain:
License.id, Customer.name, Product.name
Now the result
I am getting is a list of KeyedTuples
. How can I access the required columns from those? e.g. result[0].name
gives only Customer.name
, then how to get Product.name
as well?
Upvotes: 16
Views: 7707
Reputation: 780851
Use the label
method:
Customer.name.label("Customer_name"),\
Product.name.label("Product_name").\
Upvotes: 20