python - 使用executemany入库产生pymysql.err.ProgrammingError
天蓬老师
天蓬老师 2017-04-18 10:27:27
0
1
1427

错误如下: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.50\n')' 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有標準的讀取一行數據的文件操作方法,

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!