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

错误如下: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 학습자의 빠른 성장을 도와주세요!