#!/usr/bin/env python
#encoding=utf-8
import MySQLdb
try:
conn=MySQLdb.connect(host="192.168.8.7",user="root",passwd="xx",db="test")
cur=conn.cursor()
cur=execute("SET autocommit=0")
cur=execute("CALL sp_rollback_demo")
cur.execute("COMMIT")
except Exception,e:
cur.execute("ROLLBACK")
print e
#encoding=utf-8
import MySQLdb
try:
conn=MySQLdb.connect(host="192.168.8.7",user="root",passwd="xx",db="test")
cur=conn.cursor()
cur=execute("SET autocommit=0")
cur=execute("CALL sp_rollback_demo")
cur.execute("COMMIT")
except Exception,e:
cur.execute("ROLLBACK")
print e
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29620572/viewspace-1815006/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29620572/viewspace-1815006/