Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设一个foo具有复合主键的表(a,b),我如何使用 SQLAlchemy(postgresql 方言)生成以下 sql 查询?
foo
(a,b)
SELECT * FROM foo WHERE (a,b) IN ((1,2), (2,3));
这是答案:
from sqlalchemy.sql.expression import Tuple session.query(Foo).filter(Tuple(Foo.a, Foo.b).in_([(1,2), (3,4)])).all()