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
Post a Comment