sqlalchemy delete object
Posted buxizhizhoum
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlalchemy delete object相关的知识,希望对你有一定的参考价值。
In SQL Alchemy you are deleting Objects that you get with a query from the database. This you can do in 2 Ways:
Deleting with query (will issue just one DELETE statement):
session.query(User).filter(User.id==7).delete()
session.commit()
Deleting object instance returned by a query (will issue 2 statements: first SELECT, then DELETE):
obj=session.query(User).filter(User.id==7).first()
session.delete(obj)
session.commit()
from: https://stackoverflow.com/a/26643978/8025086
以上是关于sqlalchemy delete object的主要内容,如果未能解决你的问题,请参考以下文章
ON_DELETE="CASCADE" 不适用于 flask-sqlalchemy
如何使用 sqlalchemy_utils.dependent_objects()?
奇怪的 SQLAlchemy 错误消息:TypeError: 'dict' object does not support indexing