python3中pymysql模块的事务操作

时间:2019-05-21 13:24:39   收藏:0   阅读:784
try:
    cursor.execute(sql_1)  
    cursor.execute(sql_2)  
    cursor.execute(sql_3)  
except Exception as e:
    connect.rollback()  # 事务回滚
    print(‘事务处理失败‘, e)
else:
    connect.commit()  # 事务提交
    print(‘事务处理成功‘, cursor.rowcount)# 关闭连接
cursor.close()
connect.close()

原文:https://www.cnblogs.com/quzq/p/10898860.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!