码迷,mamicode.com
首页 > 数据库 > 详细

sqlalchemy delete object

时间:2019-05-31 19:58:24      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:sel   The   ack   objects   you   turned   state   cts   let   

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

标签:sel   The   ack   objects   you   turned   state   cts   let   

原文地址:https://www.cnblogs.com/buxizhizhoum/p/10956978.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!