鍍金池/ 問(wèn)答/Python  數(shù)據(jù)庫(kù)/ python 插入mysql 數(shù)據(jù)庫(kù)報(bào)錯(cuò)

python 插入mysql 數(shù)據(jù)庫(kù)報(bào)錯(cuò)

sql3 = "update  account set account_fullname=%s,account_id_from_media=%s, funds=%s,agency_id=8,media_id=4 where media_id=4 and account_id_from_media=%s;" %(
                 manage_page_data[i-9], manage_page_data[i-9], manage_page_data[i-9 +1] ,manage_page_data[i - 9 + 1])
                 
                 

pymysql.err.InternalError: (1054, u"Unknown column 'u5149u6c47u4e91u6cb9' in 'field list'")

報(bào)錯(cuò)這個(gè) 對(duì)應(yīng)的 manage_page_data[i-9] ,請(qǐng)問(wèn)這里改成什么類(lèi)型?才可以運(yùn)行成功,謝謝 圖片描述

回答
編輯回答
近義詞

sql3 = "update account set account_fullname='%s',account_id_from_media='%s', funds='%s',agency_id=8,media_id=4 where media_id=4 and account_id_from_media='%s';" %(manage_page_data[i-9], manage_page_data[i-9], manage_page_data[i-9 +1] ,manage_page_data[i - 9 + 1])

2017年12月2日 02:32
編輯回答
櫻花霓

你的語(yǔ)句中%s 是不是沒(méi)有格式化到?好好檢查你的sql,99%都是你的sql語(yǔ)句寫(xiě)錯(cuò)了。

2018年7月24日 10:24
編輯回答
未命名

建議使用參數(shù)化執(zhí)行sql語(yǔ)句

sql3 = "update account set account_fullname=%s, account_id_from_media=%s, funds=%s, agency_id=8,media_id=4 where media_id=4 and account_id_from_media=%s;" 

cursor.execute(sql3, (manage_page_data[i-9], manage_page_data[i-9], manage_page_data[i-9 +1] ,manage_page_data[i - 9 + 1]))
2017年12月16日 02:54
編輯回答
耍太極

自己輸出一下,你那個(gè)sql是啥。。。。%s 你沒(méi)加在引號(hào)中。

2017年11月19日 12:09