Another possible approach is using the sql module to build the query: from sqlalchemy import sql ids = [1,2,3] query = sql.select([Table.col1, Table.col2], Table.id.in_(ids)) session.execute(query)
I'm not sure how that fits into the larger context of what you're doing, but it's flexible and pretty easy to build the queries dynamically. -Eric On Tue, Jan 24, 2012 at 7:40 AM, Conor <[email protected]> wrote: > On 01/22/2012 01:49 PM, alex bodnaru wrote: > > hello friends, > > > > i'm using sa at a quite low level, with session.execute(text, dict) > > > > is it possible to do something in the spirit of: > > > > session.execute("select * from tablename where id in (:ids)", > dict(ids=[1,2,3,4])) ? > > > > thanks in advance, > > alex > > > > I'm not aware of a general way to do this. If you are using > PostgreSQL+psycopg2, you can use the = ANY(...) operator instead of the > IN operator: > > session.execute("select * from tablename where id = ANY (:ids)", > dict(ids=[1,2,3,4])) > > -Conor > > -- > 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. > > -- 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.
