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)該是換行符號的錯誤,因?yàn)榭吹侥愕腻e誤里有’8209313.50n’,從文件取出一行數(shù)據(jù)你的換行符號每處理,python有標(biāo)準(zhǔn)的讀取一行數(shù)據(jù)的文件操作方法,
相關(guān)文章:
1. mysql - sql 左連接結(jié)果union右連接結(jié)果,導(dǎo)致重復(fù)性計(jì)算怎么解決?2. javascript - 滾動到指定高度 開始輪流放動畫,QQPC官網(wǎng)就是這么做的,請問使用什么開源庫方便點(diǎn)?3. mysql 遠(yuǎn)程連接出錯10060,我已經(jīng)設(shè)置了任意主機(jī)了。。。4. 默認(rèn)輸出類型為json,如何輸出html5. 數(shù)組排序,并把排序后的值存入到新數(shù)組中6. php多任務(wù)倒計(jì)時求助7. mysql怎么表示兩個字段的差8. 怎么能做出標(biāo)簽切換頁的效果,(文字內(nèi)容隨動)9. PHP訂單派單系統(tǒng)10. MySQL的聯(lián)合查詢[union]有什么實(shí)際的用處
