mysql设置不主动提交无效_关闭事务自动提交无效,回滚也无效
我是通過(guò)看數(shù)據(jù)庫(kù)里面數(shù)據(jù)確認(rèn)的。代碼比較類(lèi)似,就這么多
#!/usr/bin/python
from MySQLdb import connect
conn = connect(db="test", user="root", host="localhost", unix_socket="/var/lib/mysql/mysql.sock")
cur = conn.cursor()
sql_insert = "insert into test_table(id,name) values('6','f')"
sql_update = "update test_table set name='A' where id ='1'"
sql_delete = "delete from test_table where id>'4'"
conn.autocommit(False)
try:
cur.execute(sql_insert)
print cur.rowcount
cur.execute(sql_update)
print cur.rowcount
cur.execute(sql_delete)
print cur.rowcount
except Exception as e:
print e
conn.rollback()
cur.close()
conn.close()
總結(jié)
以上是生活随笔為你收集整理的mysql设置不主动提交无效_关闭事务自动提交无效,回滚也无效的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: vue 音乐盒app_VBox 一款基于
- 下一篇: vc2010访问局域网mysql_VC2