import pymysqldb = pymysql.connect(host='localhost', port=3306, user='root', passwd='123456', database='test_123', charset='utf8')# 创建游标cur = db.cursor()try:# 插入操作sql = "insert into table1 values \(100,'Jank',28,'1994-12-12');"cur.execute(sql)# 修改操作sql = "update table1 set age=18 where name = 'Frank';"cur.execute(sql)# 删除操作sql = "delete from table1 where age>35;"cur.execute(sql)db.commit()except Exception as e:db.rollback()print("Failed:", e)cur.close()db.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。