import pymysql#打开数据库连接db= pymysql.connect(host="w1.mengting.win",user="root", password="ABCabc123!",db="ZjiteQueryData",port=3306)# 使用cursor()方法获取操作游标cur = db.cursor()sql_insert ="""insert into UserInfo(Uid,Pwd,Run,Szf) values(4,'liu','1234')"""try: cur.execute(sql_insert) #提交 db.commit()#print('abcc')except Exception as e: #错误回滚 db.rollback()finally: db.close()