报错的程序:
#!/usr/bin/env python
#encoding=utf-8
import MySQLdb
try:
conn=MySQLdb.connect(host="192.168.10.12",user="gw",passwd="gw",db="gw")
cur=conn.cursor()
cur.execute("set autocommit=0")
cur.execute("call sp_auto_rollback_demo3")
cur.execute("commit")
except exception,e:
cur.execute("rollback")
print e
正确的程序:
#!/usr/bin/env python
#encoding=utf-8
import MySQLdb
try:
conn=MySQLdb.connect(host="192.168.10.12",user="gw",passwd="gw",db="gw")
cur=conn.cursor()
cur.execute("set autocommit=0")
cur.execute("call sp_auto_rollback_demo3")
cur.execute("commit")
except Exception,e:
cur.execute("rollback")
print e
原因:
python大小写敏感