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
**我是新手,剛開始學python,請問問題出在哪了?
問題解答
回答1:應該是換行符號的錯誤,因為看到你的錯誤里有’8209313.50n’,從文件取出一行數(shù)據(jù)你的換行符號每處理,python有標準的讀取一行數(shù)據(jù)的文件操作方法,
相關文章:
1. python - 有什么好的可以收集貨幣基金的資源?2. docker容器呢SSH為什么連不通呢?3. docker鏡像push報錯4. docker安裝后出現(xiàn)Cannot connect to the Docker daemon.5. docker start -a dockername 老是卡住,什么情況?6. docker網(wǎng)絡端口映射,沒有方便點的操作方法么?7. node.js - nodejs debug問題8. MySQL數(shù)據(jù)庫中文亂碼的原因9. Docker for Mac 創(chuàng)建的dnsmasq容器連不上/不工作的問題10. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””
