我正在尝试更新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()
。
添加回答
举报
0/150
提交
取消