Flask-SQLAlchemy how to delete all rows in a single table

后端 未结 3 783
礼貌的吻别
礼貌的吻别 2020-12-08 00:10

How do I delete all rows in a single table using Flask-SQLAlchemy?

Looking for something like this:

>>> users = models.User.query.all()
>         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 00:21

    Try delete:

    models.User.query.delete()
    

    From the docs: Returns the number of rows deleted, excluding any cascades.

提交回复
热议问题