python - 使用executemany入库产生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’,从文件取出一行数据你的换行符号每处理,python有标准的读取一行数据的文件操作方法,
相关文章:
1. javascript - html5的data属性怎么指定一个function函数呢?2. javascript - Express 和 request 如何代理远程图片?3. python - 在使用Pycharm时经常看到如下的样式,小括号里红色的部分是什么意思呢?4. javascript - 你们怎样实现前端分页的?5. javascript - 移动端粘贴事件,onpaste事件在app中无效,在app中怎么监测到粘贴事件6. android - react-native 的headless.js Java API 的代码怎么使用?7. javascript - 关于fullpage.js 自动高度失效的问题8. python - Scrapy存在内存泄漏的问题。9. javascript - 原生canvas中如何获取到触摸事件的canvas内坐标?10. angular.js - angular2 有什么cool的loading组件么?
