鱼C论坛

 找回密码
 立即注册
查看: 2034|回复: 2

python操作mysql的update没有报错,但是数据库没有更新数据

[复制链接]
发表于 2022-8-3 20:29:05 | 显示全部楼层 |阅读模式
5鱼币
源码如下





  1. import pymysql
  2. db = pymysql.connect(host = '10.183.137.11',user='root',passwd='123456',database='xinyidai')
  3. cursor = db.cursor();
  4. cursor.execute("select * from t_xinyidai_getcookie where cookie = '' limit 1");
  5. data = cursor.fetchone();
  6. print(data[0],data[1],data[2])
  7. print(data);
  8. try:
  9.     cursor.execute("""set names gbk""");
  10.     cursor.execute("""update t_xinyidai_getcookie set cookie = 'jdpt.session.id=eb3ca5335633409685e8461a0929428f' where info = '获取池州总包cookie'""");
  11.     db.commit();

  12. except:
  13.     print("chucuo");
复制代码


源码中连接数据库,查询数据库版本都是正常的,执行update也没有问题,但是数据库中没有update提交的数据,请问如何解决

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-8-3 23:31:27 | 显示全部楼层
connect时指定编码试试。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2022-8-3 23:35:08 | 显示全部楼层
ba21 发表于 2022-8-3 23:31
connect时指定编码试试。

嗯嗯,刚才我也想到了这一点,准备明天去办公室试一下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-26 12:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表