What's the best way to query, with the ORM, based on a list of multiple 
parameters without looping over each parameter tuple?  

I have a list of parameters say:

Col-1, Col-2
a, b
c, d

where the combination of the parameters in one row defines a unique table 
entry.  Such that I would normally do 

object = session.query(table).filter(table.Col-1 == a, table.Col-2 == 
b).one()  , and 
object = session.query(table).filter(table.Col-1 == c, table.Col-2 == 
d).one()

to retrieve the two table objects

Can I run a query that would grab the list of objects all at once, in one 
query, without having to loop over each row, doing each query, and 
combining the objects into a list?  Something akin to the 
table.Col-1..in_([list of values) but with a combinatorial component to it. 
 

I know I can do something like 
session.query(table).filter(table.Col-1.in_([a,c]).all()  to grab all the 
objects that have column 1 values of a, or c, but I need to constrain those 
to a+b, and c+d

Does this make sense?

Cheers, Brian
 

-- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to