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. python - requests post问题2. 怎样写一个时间到了或是有订单的语音提醒呢?3. linux - python 安装 Anaconda 环境变量问题请教4. 如何解决tp6在zend中无代码提示5. Mysql 组合索引最左原则的疑惑6. pdo_mysql 值自增写法7. python - 怎样在linux下开发flask web应用时查看代码出错(traceback)的地方。8. python - 用ffmpeg采集视频,用terminate没法结束进程9. python3.x - python多进程,不能在同一窗口吗10. PHP中的$this代表当前的类还是方法?

网公网安备