python - 使用executemany入庫產(chǎn)生pymysql.err.ProgrammingError
問題描述
錯誤如下: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)該是換行符號的錯誤,因為看到你的錯誤里有’8209313.50n’,從文件取出一行數(shù)據(jù)你的換行符號每處理,python有標(biāo)準(zhǔn)的讀取一行數(shù)據(jù)的文件操作方法,
相關(guān)文章:
1. docker鏡像push報錯2. 關(guān)docker hub上有些鏡像的tag被標(biāo)記““This image has vulnerabilities””3. 關(guān)于docker下的nginx壓力測試4. docker - 如何修改運(yùn)行中容器的配置5. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題6. angular.js - angularjs的自定義過濾器如何給文字加顏色?7. 前端 - @media query 使用出現(xiàn)的問題?8. html - css氣泡,實現(xiàn)“倒三角(不知道算不算三角了)”可透明的。9. html5和Flash對抗是什么情況?10. java - 如何點(diǎn)擊按鈕,重新運(yùn)行(我是初學(xué)者)?

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