在LOAD DATA LOCAL INFILE整数所需的错误

时间:2016-09-02 19:01:52

标签: python mysql mysql-python mysql-connector-python

我有一个包含以下格式数据的数据文件

asd,12,asd,asd,12,adsd,,asdas,None

我在mysql中有一个表,其中auto incrementid,其余列在数据文件中。

现在我正在尝试

query2 = """LOAD DATA LOCAL INFILE 'tmp.txt'
             REPLACE INTO TABLE mytable
             FIELDS TERMINATED BY ','
             LINES TERMINATED BY '\\n'
             (a1,a2,a3,a4,a5,a6,a7,a8,a9)
            """

conn = mysql.connector.connect(user=self.db_config.dbusername, password=self.db_config.dbpassword,
                                       host=self.db_config.dbhost,
                                       database='something', client_flags=[ClientFlag.LOCAL_FILES]) 
cursor = conn.cursor()
cursor.execute(query2)
conn.commit()
cursor.close()
conn.close()

我得到的错误是

  

class'mysql.connector.errors.InterfaceError'>执行操作失败;需要一个整数

由于存在自动增量ID我尝试按照某些帖子的建议添加SET ID=None,但结果是相同的.tmp.txt与脚本位于同一位置。此响应由mysql服务器发送

MYSQL Server is on amazon是一个差异。

知道是什么导致了这个或我们如何调试它?

深入挖掘。

错误来自

execute method in /usr/local/lib/python2.7/site-packages/mysql/connector/cursor.py is called with the query as parameter

cmd_query in /usr/local/lib/python2.7/site-packages/mysql/connector/protocol.py is called 

_handle_resultset in /usr/local/lib/python2.7/site-packages/mysql/connector/protocol.py is called 

read_lc_int in /usr/local/lib/python2.7/site-packages/mysql/connector/utils.py is called which return (buf,None)

所以_handle_resultset函数失败。所以这肯定与发送LOAD DATA查询时来自服务器的响应有关。

0 个答案:

没有答案