必要时实现rollback

# from pymysql import connect

# # #创建Connection连接

# conn = connect(host = 'localhost',port = 3306,user = 'root' ,password = 'hezhuang',database = 'TCL',charset = 'utf8')

# # #  获得Cursor对象

# cursor = conn.cursor()

# # print(cursor.execute(''' into goods_cates(name) value("硬盘1")'''))

# # print(cursor.execute(''' into goods_cates(name) value("硬盘2")'''))

# # print(cursor.execute(''' into goods_cates(name) value("硬盘3")'''))

# conn.commit()

# #报错原因是

# #双引号嵌套,可以使用三个引号。来代表完整字符串

# print(cursor.execute(''' into goods_cates(name) value("硬盘3")'''))

# print(cursor.execute(''' into goods_cates(name) value("硬盘4")'''))

# #假如执行代码有错时可以先执行

# conn.rollback()

# #重新回滚

# print(cursor.execute(''' into goods_cates(name) value("硬盘4")'''))

# conn.commit()

#报错原因是

#双引号嵌套,可以使用三个引号。来代表完整字符串

你可能感兴趣的:(必要时实现rollback)