python - 使用executemany入庫產(chǎn)生pymysql.err.ProgrammingError
問題描述
錯(cuò)誤如下:pymysql.err.ProgrammingError: (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 ’’2016/12/05’,’0935’,’9.56’,’9.56’,’9.38’,’9.40’,’869500’,’8209314.50n’)’ at line 1')
**插入語句如下:
insert='insert into sz values(%s,%s,%s,%s,%s,%s,%s,%s)'
for f in glob.glob(self.fdir+os.sep+'*.txt'):
ifile=open(f,’r’)for line in ifile: line=line.split('t') linelist.append(line)ifile.close() try:cursor.executemany(insert,linelist) except IndexError:pass
**我是新手,剛開始學(xué)python,請問問題出在哪了?
問題解答
回答1:應(yīng)該是換行符號的錯(cuò)誤,因?yàn)榭吹侥愕腻e(cuò)誤里有’8209313.50n’,從文件取出一行數(shù)據(jù)你的換行符號每處理,python有標(biāo)準(zhǔn)的讀取一行數(shù)據(jù)的文件操作方法,
相關(guān)文章:
1. javascript - sublime快鍵鍵問題2. javascript - immutable配合react提升性能?3. vue.js - Vue 如何像Angular.js watch 一樣監(jiān)聽數(shù)據(jù)變化4. 如何解決Centos下Docker服務(wù)啟動(dòng)無響應(yīng),且輸入docker命令無響應(yīng)?5. 實(shí)現(xiàn)bing搜索工具urlAPI提交6. javascript - 移動(dòng)端上不能實(shí)現(xiàn)拖拽布局嗎?7. angular.js - 單頁應(yīng)用(ng/vue)該如何監(jiān)聽用戶離開當(dāng)前頁面(或者路由)?8. javascript - ios返回不執(zhí)行js怎么解決?9. thinkPHP5中獲取數(shù)據(jù)庫數(shù)據(jù)后默認(rèn)選中下拉框的值,傳遞到后臺消失不見。有圖有代碼,希望有人幫忙10. index.php錯(cuò)誤,求指點(diǎn)

網(wǎng)公網(wǎng)安備