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. css - 图片的宽度发生变化而高度却没有相应变?2. python for循环中的函数只能运行一次?3. dockerfile - 为什么docker容器启动不了?4. web服务器 - ubuntu下布置apache加wsgi加python5. docker 17.03 怎么配置 registry mirror ?6. css3 - 背景图自定义比例缩小7. tp6 事务闭包操作问题8. javascript - sublime快键键问题9. javascript - 微信小程序 如何实现这种左滑动出现删除的办法?有相关api吗?10. 主从复制 - MySQL 主从延迟 300s 以上,求大神解答

网公网安备