Everyone - TIA for any help. Here's my situation - I've got a large
number of different tables that all have the same columns. I'd like
to treat these tables as one giant table that I can query against. I
thought I could do this by unioning all the tables, making a subquery
and using the arbitrary "c" attribute, but I'm not successful in the
slightest. Here's what I'm trying to do in some pseudo code:
queries = []
for table_class in table_classes:
q = Session.query(table_class)
q = q.filter(<some filters>)
queries.append(q)
q = queries[0].union_all(*queries[1:])
q = q.subquery
alias1 = aliased(some_table_1)
uber_query = Session.query( alias1.col1, alias1.col2, q.c.col1,
q.c.col2)
The idea is that the tables that all have the same columns will be
represented by 'col1' and so on. But, well, this isn't working. I
realize my approach may not be correct, I'll take any help I can
get.
Tremendous thanks to anyone who reads this,
Carl
--
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.