[sqlalchemy] Re: How can I join to a query/subquery column?

2013-11-06 Thread Jonathan Vanasco
You can do something like: q1 = session.query(\ ContactInfo.account_id.label(q1_account_id ), ContactInfo.other_id.label(q1_otherid ) )\ .filter(..) q2 = session.quiery(Site.account_id.label(q2_account_id)).filter(..) _q3 =

[sqlalchemy] Re: How can I join to a query/subquery column?

2013-11-06 Thread Jonathan Vanasco
sidenote: there are typos. that's just to illustrate. i mostly copied that from production code. the core concepts are: 1. `label()` the columns 2. use the `engine` (not orm) to join the queries 3. `alias` the union to search against them 4. the labeled columns in the earlier queries are now

[sqlalchemy] Re: How can I join to a query/subquery column?

2013-11-06 Thread John Kida
Thanks guys, so i got it going with the hint to use an alias. Here is what i ended up getting to work... BUT*** i am not using the engine.execute does .all() work.. but its not recommended because im not having a problem whats the issue? Here is what im doing. q3 = union(q1,q2).cte() q =

[sqlalchemy] Re: How can I join to a query/subquery column?

2013-11-06 Thread Jonathan Vanasco
i think the call to alias ( making it a subquery ) dropped the support for all in my example; though that was written in .8.1 -- might be working since .8.3 or 9 it took me a bit of trial and error to get stuff working. awesome that it's working for you so quickly! -- You received this