我正在嘗試更新MySQL DB中的數(shù)據(jù),但它拋出錯誤: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'>)"我的表結(jié)構(gòu)是:+--------------------+---------------+------+-----+---------+-------+| 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貢獻(xiàn)1909條經(jīng)驗 獲得超7個贊
由所有Python SQL庫實現(xiàn)的Python數(shù)據(jù)庫API使用已參數(shù)化的查詢-本手冊中沒有涉及到PHP中常見的無用的參數(shù)廢話轉(zhuǎn)義。您需要%s
在查詢中的s周圍舍棄單引號,而不是使用%
運算符手動(且容易注入)將參數(shù)格式化為查詢格式,而%
用逗號替換,
以將參數(shù)作為第二個參數(shù)傳遞給execute()
。
添加回答
舉報
0/150
提交
取消