Re: [sqlalchemy] How to label columns of a union?

2016-01-18 Thread Mike Bayer
you'd probably want to specify literal SQL and use label(): literal_column('1').label('bar') On 01/17/2016 10:54 AM, 'Dr. Leo' via sqlalchemy wrote: > Hi, > > consider the following snippet: > > > from sqlalchemy import select, union > u=union(select([1]).alias('foo'), select([2]).alias('foo

[sqlalchemy] How to label columns of a union?

2016-01-17 Thread 'Dr. Leo' via sqlalchemy
Hi, consider the following snippet: from sqlalchemy import select, union u=union(select([1]).alias('foo'), select([2]).alias('foo')) u.c.keys() ['1'] u.c['1'] ua=u.alias('bar') s=select().select_from(ua) ... "1" is neither a Python, nor an SQL identifier. This makes it impossible to refer to