pymql练习,修改数据

上代码:

# -*- coding:utf-8 -*-  
import pymysql
con=pymysql.connect(host='localhost',user='root',password='123456',database='ges_data',port=3306)
cur=con.cursor()
sql='update t_student set age=%s where sno=%s'

try:
    cur.execute(sql,(17,1))
    con.commit()
except Exception as e:
    print(e)
    con.rollback()
finally:
    con.close()
发布了15 篇原创文章 · 获赞 12 · 访问量 222

猜你喜欢

转载自blog.csdn.net/weixin_45116096/article/details/105471536
今日推荐