On 08/16/2010 04:47 PM, Michael Hipp wrote:
> I'm doing something like this where each Item has 2 ForeignKeys to
> Dealer for buyer and seller:
>
>   seller = dealers.alias('seller')
>   buyer = dealers.alias('buyer')
>   engine.execute(select([items, seller.c.name, buyer.c.name]).fetchall()
>
> When I do this the seller and buyer name end up in the results and are
> both called 'name' which isn't very useful. If I add 'use_labels=True'
> it messes up all the column names from items.
>
> Is there some way to just have it alias them to seller_name and
> buyer_name? It's easy to do in pure sql.
>
> Thanks,
> Michael
>
Try this:

engine.execute(select([items, seller.c.name.label("seller_name"), 
buyer.c.name.label("buyer_name")])).fetchall()

-Conor

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to