以下代码运行时没有错误,但数据库不会影响。 这意味着无法删除记录。 Python中的部分代码
import MySQLdb as msdb
def delete_row(self):
con = msdb.connect('localhost','root','24434','matab_db')
cur = con.cursor()
qq = "DELETE FROM tbl_rezerv_nobat WHERE id=4"
# or qq = "DELETE FROM tbl_rezerv_nobat WHERE id='4'"
bb = cur.execute(qq)
con.close()
由于
答案 0 :(得分:0)
您还应该在con.commit()
con.close()
即
def delete_row(self):
con = msdb.connect('localhost','root','24434','matab_db')
cur = con.cursor()
qq = "DELETE FROM tbl_rezerv_nobat WHERE id=4;"
# or qq = "DELETE FROM tbl_rezerv_nobat WHERE id='4'"
bb = cur.execute(qq)
con.commit()
con.close()