> -----Original Message----- > From: sqlalchemy@googlegroups.com > [mailto:sqlalch...@googlegroups.com] On Behalf Of JanW > Sent: 17 April 2009 14:45 > To: sqlalchemy > Subject: [sqlalchemy] Re: mapping class against arbitrary SQL > expression > > > OK, thanks, > > it does work if you make an alias on the select like this: > s = select([left.c.car_id, > left.c.temperature.label('left_temperature'), > right.c.temperature.label('right_temperature')], > from_obj=tables, > whereclause=and_(left.c.side == 'left', > right.c.side == 'right')).alias('carside') > > Thanks a lot! > > Now, is it really needed to translate my SQL query first to SA-speak > or could I use the SQL directly in some way? (I have many old projects > with SQL embedded in Perl scripts, so it would be someway easier is I > can transfer the SQL directly). > > From session.query() there is something like from_statement > (SQL_string) but that won't work here I think. > > Again, many thanks, > > Jan. >
I don't know the answer, but I suspect this will be a problem. I think SA needs to know what columns are going to be returned from the select statement so that it can set up properties on the mapped class. I don't know of any way that you can mark a text block as a Selectable. Sorry I can't be more help, Simon --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---