环境:MySQL-python-1.2.3.win-amd64-py2.7
python-2.7.amd64
mysql-installer-community-5.6.12.2
Windows Server 2008 R2数据中心
我在用python脚本插入数据时遇到了操作错误1366。我需要运行2010年的EPFImporter
我认为问题是MySQLdb只能处理uft8,而不能{}。我需要导入的数据包含utf8mb4字符,我不能删除它们。在
在成功插入约70.000行之后,从CMD comand行运行该脚本时,会出现以下错误消息:2013-07-31 15:14:53,460 [ERROR]: Fatal error encountered while ingesting 'C:\webserver\www\site1\assets\scripts
Traceback (most recent call last):
File "C:\webserver\www\site1\assets\scripts\EPFImporter\EPFIngester.py", line 129, in ingestFull
self._populateTable(self.tmpTableName, skipKeyViolators=skipKeyViolators)
File "C:\webserver\www\site1\assets\scripts\EPFImporter\EPFIngester.py", line 379, in _populateTable
cur.execute(exStr)
File "C:\Windows\python\lib\site-packages\MySQLdb\cursors.py", line 174, in execute
self.errorhandler(self, exc, value)
File "C:\Windows\python\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
OperationalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x98\\x8A A...' for column 'description' at row 1")
我准备好了:
^{pr2}$
我把以下内容从INNODB改为:default storage engine MyISAM Documentation
default tmp storage engine MyISAM
在此更改之前,它根本没有导入任何行。在
我还能做什么?一般来说,它应该可以工作,因为在共享主机上,我在MySQL服务器版本5.5.28上运行它,它工作得很好
EDIT1:为了测试,我安装了最新的XAMPP版本,并且在XAMPP下,脚本运行良好,只运行XAMPP MySQL服务器而不是Apache。Python和MySQLdb版本与以前一样,没有受到任何影响。所以我现在很确定我在MySQL服务器的配置上做错了什么。在XAMPP中,数据库使用InnoDB引擎运行。在
以下是XAMPP MYSQL服务器的规范:Server: 127.0.0.1 via TCP/IP
Server type: MySQL
Server version: 5.6.11 - MySQL Community Server (GPL)
Protocol version: 10
User: root@localhost
Server charset: UTF-8 Unicode (utf8)
有人知道我能做些什么来追踪我最初安装的MySQL时的问题吗?可能是变量设置、MYSQL错误处理还是Python连接器?在