Hello there,

I'm looking into the cheapest way of, in core, building collections into
each row on fairly large left and right tables (the collections themselves
are small though). By collection i mean the same thing as in sqlalchemy
orm: an outer left join, that to each row of the left table with I add an
extra "column" referencing a list of rows on the right table matching the
join criteria.

Right now I'm using a two-query + stitch approach
1- a simple select on the left table.
2- an inner join on the right table using the same where clause as the
query above but returning only columns of the right table.
3- iterate over the left table result to build a dict where the key is the
pk, and the value the row itself.
4- iterate over the right table result, and append each row to a new column
on the referenced left table row.

The above can be done programmatically and it works fine for two table
joins. And the only reason I'm doing this way is that I could not figure
out how to programmatically find which columns in the result of a join
belong to each table without hardcoding column names.

But now I need a bunch of 3-table outer joins, and I believe using one big
join would be the way to go, but again I'd like to avoid hardcoding column
names if possible.

So here are my questions:
- is it possible to know which columns in the result of a join belong to
each of the tables?
- is there a more efficient way of building collections with core? It makes
me cringe to load large resultsets in memory and iterate over them several
times :)

Thank you very much :)
G.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to