import pymysql
con = pymysql.connect(host = 'localhost',user = 'root',password = '123456',database = 'python_db',port = 3306)
# 创建游标对象
cur = con.cursor()
sql = 'update students set name = %s where id = %s'
# 执行sql语句
try:
cur.execute(sql,('飞飞',1))
#提交事务
con.commit()
print('修改成功')
except Exception as e:
print(e)
print('修改失败')
finally:
con.close()