我正在使用 flask-sqlalchemy,我的问题是 where in 子句如下:
select * from table_1 where id in (1,2,3,5)
OR
select * from table_1 where field_1_id in (select id from table_2 where .... )
和 get_or_create 像 peewee orm
Object.get_or_create(.......)
我如何用 flask-sqlalchemy 生成这个句子?
最佳答案
尝试 .in_ clause在 sqlalchemy 中
result = db_session.query(table_1).filter(table_1.id.in_((1,2,3,5))).all()
注意:这里假设 table_1 是您的模型
关于python - flask-sqlalchemy where in 子句查询语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22420598/