Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/324.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在windows7上使用Python 2.7将CSV转换为Mysql_Python_Csv_Mysql Python - Fatal编程技术网

在windows7上使用Python 2.7将CSV转换为Mysql

在windows7上使用Python 2.7将CSV转换为Mysql,python,csv,mysql-python,Python,Csv,Mysql Python,当我尝试运行我的代码时,我遇到了以下错误: “回溯(最近一次呼叫最后一次): 文件“C:/Python27/mysql2.py”,第7行,在 cursor.execute(query2) 文件“C:\Python27\lib\site packages\MySQLdb\cursors.py”,第219行,在execute中 errorhandler(self、exc、value) defaulterrorhandler中第38行的文件“C:\Python27\lib\site packages

当我尝试运行我的代码时,我遇到了以下错误:

“回溯(最近一次呼叫最后一次):
文件“C:/Python27/mysql2.py”,第7行,在
cursor.execute(query2)
文件“C:\Python27\lib\site packages\MySQLdb\cursors.py”,第219行,在execute中
errorhandler(self、exc、value)
defaulterrorhandler中第38行的文件“C:\Python27\lib\site packages\MySQLdb\connections.py”
提高错误值
操作错误:(1300,'无效的utf8字符串:\'“\''”
此位

LINES TERMINATED BY '\n' 
由Python解释并表示换行符。但您确实希望将
\n
传递给查询

使用原始字符串:

query2 = r'''LOAD DATA LOCAL INFILE "C:/Python27/output.csv" INTO TABLE (etc)'''