search

Home  >  Q&A  >  body text

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.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,请问问题出在哪了?

天蓬老师天蓬老师2785 days ago1465

reply all(1)I'll reply

  • 阿神

    阿神2017-04-18 10:29:27

    It should be a newline symbol error, because I saw '8209313.50n' in your error. When taking out a line of data from the file, your newline symbol is processed. Python has a standard file operation method for reading a line of data.

    reply
    0
  • Cancelreply