> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Michele Simionato
> Sent: 17 August 2009 16:11
> To: sqlalchemy
> Subject: [sqlalchemy] renaming columns
>
>
> There should be an easy way to do this, but I cannot find it in the
> documentation.
> I would like to generate a query with a renamed column, something like
> this:
>
> SELECT acolumn AS newcol FROM atable
>
> I tried things like
>
> print atable.select().with_only_columns([atable.c.acolumn.as_
> ('newcol')])
>
> What's the right syntax? Thanks,
>
> M.S.
I think you want something like <column>.label('newcol'). For example:
import sqlalchemy as sa
print sa.select([atable.c.acolumn.label('newcol')])
Hope that helps,
Simon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---