Re: [sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-23 Thread Michael Bayer
On Feb 23, 2013, at 1:13 AM, Eric Rasmussen ericrasmus...@gmail.com wrote: But that's just a long-winded way to express a reduce operation*, so for your example you could also write: import sqlalchemy as sa criteria = (('male', 35), ('female', 35)) Useraccount =

Re: [sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-22 Thread Simon King
On Fri, Feb 22, 2013 at 1:31 AM, Jonathan Vanasco jonat...@findmeon.com wrote: basd on a bunch of error messages, this example works... criteria = ( ('male',35),('female','35) ) query = session.query( model.Useraccount ) ands = [] for set_ in criteria :

Re: [sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-22 Thread Conor
On 02/21/2013 07:31 PM, Jonathan Vanasco wrote: basd on a bunch of error messages, this example works... criteria = ( ('male',35),('female','35) ) query = session.query( model.Useraccount ) ands = [] for set_ in criteria : ands.append(\

Re: [sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-22 Thread Eric Rasmussen
Using sa.tuple_ looks like the nicest solution here, but back to your original question about building or clauses, expressions built with or_ can be passed as arguments to or_ to build more complex expressions. One simple iterative way to do this is: clauses = or_() # empty starting value

[sqlalchemy] is there a more proper way to chain dynamic or clauses ?

2013-02-21 Thread Jonathan Vanasco
basd on a bunch of error messages, this example works... criteria = ( ('male',35),('female','35) ) query = session.query( model.Useraccount ) ands = [] for set_ in criteria : ands.append(\ sqlalchemy.sql.expression.and_(\