Re: [sqlalchemy] any way to pre cook a monster query?

2010-01-27 Thread Chris Withers
Michael Bayer wrote: Now, is there any way I can pre-cook this (eg: at module-level) such that I can later just plug in self.id and on_date, bind to a session and call .all() on it? It seems a bit wasteful to do all the SQL generation on every query when it's almost all identical all the

Re: [sqlalchemy] Map to Arbitrary Select Using Raw SQL

2010-01-27 Thread Michael Chambliss
Michael Chambliss wrote: Michael Bayer wrote: On Jan 26, 2010, at 7:48 PM, Michael Chambliss wrote: Presently, I'm trying to determine the best way to map a class against an arbitrary select where the select is constructed from raw SQL. Based on this, it's possible using the expression

Re: [sqlalchemy] Map to Arbitrary Select Using Raw SQL

2010-01-27 Thread Michael Bayer
Michael Chambliss wrote: Hey Michael - thanks for the patient and helpful response. I played around with the from_statement() approach earlier today, but what I was able to derive seemed to follow the standard model of define table, define class, map table to class, execute query. That

Re: [sqlalchemy] any way to pre cook a monster query?

2010-01-27 Thread Michael Bayer
Chris Withers wrote: This is a bit puzzling. Surely all the taking of python Query, select, and_, join, etc objects, running them through dialects, etc and ending up with a string of sql only needs to be done once; then it should just be a case of formatting the values and plugging them into

RE: [sqlalchemy] Map to Arbitrary Select Using Raw SQL

2010-01-27 Thread King Simon-NFHD78
-Original Message- From: sqlalchemy@googlegroups.com [mailto:sqlalch...@googlegroups.com] On Behalf Of Michael Bayer Sent: 27 January 2010 16:31 To: sqlalchemy@googlegroups.com Subject: Re: [sqlalchemy] Map to Arbitrary Select Using Raw SQL Michael Chambliss wrote: Hey Michael

Re: [sqlalchemy] Map to Arbitrary Select Using Raw SQL

2010-01-27 Thread Michael Bayer
Michael Chambliss wrote: vehicle_query = select v.vehicle_id as vehicle_id, v.name as vehicle_name, v.description as vehicle_description, vt.name as vehicle_type, vs.name as vehicle_status, v.modify_dttm as vehicle_modify_dttm

Re: [sqlalchemy] any way to pre cook a monster query?

2010-01-27 Thread Antoine Pitrou
Le mercredi 27 janvier 2010 à 12:31 -0500, Michael Bayer a écrit : Or, we can generate the compiled() object, which contains the SQL string as well as a lot of important metadata about the statement used when fetching results. But this is not possible without access to a dialect and

Re: [sqlalchemy] any way to pre cook a monster query?

2010-01-27 Thread Michael Bayer
Antoine Pitrou wrote: Le mercredi 27 janvier 2010 à 12:31 -0500, Michael Bayer a écrit : Or, we can generate the compiled() object, which contains the SQL string as well as a lot of important metadata about the statement used when fetching results. But this is not possible without access to

Re: [sqlalchemy] any way to pre cook a monster query?

2010-01-27 Thread Michael Bayer
Antoine Pitrou wrote: Le mercredi 27 janvier 2010 à 12:31 -0500, Michael Bayer a écrit : Or, we can generate the compiled() object, which contains the SQL string as well as a lot of important metadata about the statement used when fetching results. But this is not possible without access to

[sqlalchemy] Translating a sql union statement into SA problem

2010-01-27 Thread werner
I am trying different solutions to my problem of getting default languages back. I have following statement: Select T1.id, T1.code_id, T1.lang_code5, T1.name from somecode_t T1 where T1.lang_code5 = 'FR_fr' UNION Select T2.id, T2.code_id, T2.lang_code5, T2.name from somecode_t T2 left outer

Re: [sqlalchemy] Map to Arbitrary Select Using Raw SQL

2010-01-27 Thread Michael Chambliss
King Simon-NFHD78 wrote: You'll have to give it a table name, which will have the effect of defining a Table object even though no such table exists in the database, but I don't think this matters. Then you could use the query that Mike suggested to actually retrieve rows Thanks, Simon - I ended

[sqlalchemy] Interface to (very old) Sybaase?

2010-01-27 Thread Adrian von Bidder
Heyho! Has anybody worked with a Sybase Anywhere (ASA 9 -- yes, very old ...) database? I may need to build a simple CRUD (actually onnly R and U ;-) frontend to some legacy application. (I probably will give TurbeGears a try for this.) I do have a JDBC driver, and I *think* ODBC should work