postgresql - SQLAlchemy: Querying compound primary key with `IN` operator -


assuming table foo compound primary key (a,b), how can generate following sql query sqlalchemy (postgresql dialect)?

select * foo (a,b) in ((1,2), (2,3)); 

here answer:

from sqlalchemy.sql.expression import tuple session.query(foo).filter(tuple(foo.a, foo.b).in_([(1,2), (3,4)])).all() 

Comments

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -