为了账号安全,请及时绑定邮箱和手机立即绑定

更新Mysql中的行

更新Mysql中的行

森林海 2021-03-16 15:14:08
我正在尝试更新MySQL DB中的数据,但它抛出错误:UPDATE scrapedDataTable  SET productDesc=,                             moreProductImages=full/545521_1363869251%20copy-500x500.jpg,full/545521_1363869251%20copy-275x275.jpg,full/545522_1363869309%20copy-500x500.jpg,full/545522_1363869309%20copy-74x74.jpg, ,productCategory=Clothing,                             productSubCategory=NA  WHERE Server=http://1click1call.com/Jeans-Shirts-Tshirts-Trousers/W-for-Woman-Kurta-54552And error:(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'moreProductImages=full/545521_1363869251%20copy-500x500.jpg,full/545521_13638692' at line 1")"(<class '_mysql_exceptions.ProgrammingError'>)"我的表结构是:+--------------------+---------------+------+-----+---------+-------+| Field              | Type          | Null | Key | Default | Extra |+--------------------+---------------+------+-----+---------+-------+| productTitle       | varchar(100)  | NO   |     | NULL    |       || productSite        | varchar(1000) | NO   |     | NULL    |       || productDesc        | text          | YES  |     | NULL    |       || productURL         | varchar(325)  | NO   | PRI | NULL    |       || productMRP         | varchar(200)  | YES  |     | NULL    |       || productPrice       | varchar(200)  | YES  |     | NULL    |       || productCategory    | varchar(50)   | YES  |     | NULL    |       || productSubCategory | varchar(50)   | YES  |     | NULL    |       || imageURL           | text          | YES  |     | NULL    |       || moreProductImages  | text          | YES  |     | NULL    |       |+--------------------+---------------+------+-----+---------+-------+询问 :cursor.execute("UPDATE scrapedDataTable  SET productDesc=%s,moreProductImages='%s', ,productCategory=%s, productSubCategory=%s  WHERE productURL=%s" %(productDesc,image_paths,productCategory,productSubCategory,productURL))谁能帮我...
查看完整描述

2 回答

?
jeck猫

TA贡献1909条经验 获得超7个赞

由所有Python SQL库实现的Python数据库API使用已参数化的查询-本手册中没有涉及到PHP中常见的无用的参数废话转义。您需要%s在查询中的s周围舍弃单引号,而不是使用%运算符手动(且容易注入)将参数格式化为查询格式,而%用逗号替换,以将参数作为第二个参数传递给execute()

查看完整回答
反对 回复 2021-03-27
  • 2 回答
  • 0 关注
  • 204 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号