SQLAlchemy: How do you delete multiple rows without querying

后端 未结 3 1592
小鲜肉
小鲜肉 2021-01-31 02:11

I have a table that has millions of rows. I want to delete multiple rows via an in clause. However, using the code:

session.query(Users).filter(Users.id.in_(sub         


        
3条回答
  •  情话喂你
    2021-01-31 03:07

    The below solution also works, if developers do not want to execute a plain vanilla query.

    session.query(Users).filter(Users.id.in_(subquery....)).delete(synchronize_session=False)
    

提交回复
热议问题