1064,“您的SQL语法中有错误

时间:2014-05-22 21:36:47

标签: python mysql sql

这是错误:

gutschy@kiste:~/pizza/pizza_daten$ python datenimport3.py
Traceback (most recent call last):
  File "datenimport3.py", line 20, in <module>
    ")
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
_mysql_exceptions.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 ''Adressliste_forum1_v4.csv'            INTO TABLE pizzeria_table             FIE' at line 1")
gutschy@kiste:~/pizza/pizza_daten$

这里是datenimport3.py

#!/usr/bin/python
#-*- coding: utf-8 -*-

import MySQLdb as mdb

con = mdb.connect('localhost', 'user', 'passw', 'pizzadb2');

with con:

    cur = con.cursor(mdb.cursors.DictCursor)
    cur.execute(" 'Adressliste_forum1_v4.csv'\
            INTO TABLE pizzeria_table \
            FIELDS TERMINATED BY ',' \
            ENCLOSED BY '\"' \
            LINES TERMINATED BY '\\n'  \
            IGNORE 1 LINES \
            (laden_name, vorwahl, telenr1, strasse, hausnr, \
            ort, linkname1, linkname2, linkname3, forum_link, \
            link2, link3, banner) \
            ")

四个月前,它的工作一切正常,比我杀死我的debian 7还要现在我以同样的方式带来它。我已经添加了最后一个字段&#34; banner&#34;新的,但我注意到了更多。

1 个答案:

答案 0 :(得分:1)

您可以通过查找以下内容对所有追踪条件进行排序:

...for the right syntax to use near ''Adressliste_forum1_v4.csv'  INTO ...

在1064错误上,MySQL在“使用附近”后立即显示从发现其解析错误的位置开始的语句。

现在,你的陈述不应该以

开头
 LOAD DATA INFILE 'Adressliste_forum1_v4.csv'  INTO ...