mysql - 导入 EPF 文件无法完成,因为得到不正确的字符串值错误

标签 mysql python-2.7 character-encoding epf

我已经为 python [MySQL-python-1.2.3.win32-py2.7] 安装了 mysql 5.5 和 mysqldb,python 版本 2.7

另外,使用字符集 utf8 创建新数据库并从 apple itunes.rar 安装并解压。

然后打开 cmd 并转到 python 目录,然后键入:EPFImporter.py itunes

itunes: 文件夹包含应用程序 EPF

运行时出现如下错误:

2014-09-02 14:49:33,706 [INFO]: Beginning import for the following directories:
    it
2014-09-02 14:49:33,707 [INFO]: Importing files in it
2014-09-02 14:49:33,709 [INFO]: Starting import of C:\Python27\app\it...
2014-09-02 14:49:33,710 [INFO]: Beginning full ingest of app00511_application (1315569 records)
2014-09-02 14:49:34,698 [ERROR]: Fatal error encountered while ingesting 'C:\Python27\app\it\application'
Traceback (most recent call last):
  File "C:\Python27\app\EPFIngester.py", line 129, in ingestFull
    self._populateTable(self.tmpTableName, skipKeyViolators=skipKeyViolators)
  File "C:\Python27\app\EPFIngester.py", line 380, in _populateTable
    cur.execute(exStr)
  File "C:\Python27\lib\site-packages\MySQLdb\cursors.py", line 202, in execute
    self.errorhandler(self, exc, value)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
OperationalError: (1366, "Incorrect string value: '\\xF0\\x9F\\x91\\x8D \\xE8...' for column 'description' at row 47")
2014-09-02 14:49:34,700 [ERROR]: Last record ingested before failure: 1200
2014-09-02 14:49:34,703 [INFO]: Import of it completed at: 14-09-02 14:49:34
2014-09-02 14:49:34,703 [INFO]: Total import time for it: 0:00:00.99
2014-09-02 14:49:34,703 [WARNING]: The following files encountered errors and were not imported:
 application
2014-09-02 14:49:34,706 [WARNING]: The following files encountered errors and were not imported:
        it/['application']
2014-09-02 14:49:34,706 [INFO]: Total import time for all directories: 0:0

我在一些文章中读到说我们应该改用 utf8mb4,但是当将 EPFIngester.py 文件中的连接字符集更改为 utf8mb4 时,如下所示:

conn = MySQLdb.connect(
        charset='utf8mb4', 
        host=self.dbHost, 
        user=self.dbUser, 
        passwd=self.dbPassword, 
        db=self.dbName)
        return conn

我遇到了这个错误:

C:\Python27\app>EPFImporter.py it
2014-09-02 14:58:33,742 [INFO]: Beginning import for the following directories:
    it
2014-09-02 14:58:33,743 [INFO]: Importing files in it
2014-09-02 14:58:33,744 [INFO]: Starting import of C:\Python27\app\it...
2014-09-02 14:58:33,746 [INFO]: Beginning full ingest of app00511_application (1
315569 records)
2014-09-02 14:58:33,769 [ERROR]: Fatal error encountered while ingesting 'C:\Pyt
hon27\app\it\application'
Traceback (most recent call last):
  File "C:\Python27\app\EPFIngester.py", line 128, in ingestFull
    self._createTable(self.tmpTableName)
  File "C:\Python27\app\EPFIngester.py", line 297, in _createTable
    conn = self.connect()
  File "C:\Python27\app\EPFIngester.py", line 240, in connect
    db=self.dbName)
  File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
    return Connection(*args, **kwargs)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 215, in __in
it__
    self.set_character_set(charset)
  File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 298, in set_
character_set
    super(Connection, self).set_character_set(charset)
OperationalError: (2019, "Can't initialize character set utf8mb4 (path: C:\\mysq
l\\\\share\\charsets\\)")
2014-09-02 14:58:33,772 [ERROR]: Last record ingested before failure: -1
2014-09-02 14:58:33,773 [INFO]: Import of it completed at: 14-09-02 14:58:33
2014-09-02 14:58:33,775 [INFO]: Total import time for it: 0:00:00.02
2014-09-02 14:58:33,775 [WARNING]: The following files encountered errors and we
re not imported:
 application
2014-09-02 14:58:33,775 [WARNING]: The following files encountered errors and we
re not imported:
        it/['application']
2014-09-02 14:58:33,776 [INFO]: Total import time for all directories: 0:00:00.0
3

我正在寻找解决这个问题的方法,但没有成功。任何人都可以面对这样的问题并有解决方案。

注意:以上所有操作均在Windows下进行。

最佳答案

我不确定,但您似乎正在导入应用程序文件而不是数据库。参见 https://www.apple.com/itunes/affiliates/resources/documentation/epfimporter.html#configure-epfimporter用于安装和设置。

关于mysql - 导入 EPF 文件无法完成,因为得到不正确的字符串值错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25622958/

相关文章:

python - 如何检查requirements.txt文件中包含哪些包?

python - 从字符串解析 graph_def 时出错

html - 带有 doctype 4.01 Transitional 的 html 中的标题标签之前有哪些元标签?

php - 通过 mysql 添加到购物车

php - 难以检查现有用户注册 php/mysqli

如果createDate每隔1天、2天、3天等过去,php如何发送电子邮件?

php - 使用 SQL 从表中获取行时出错

python - 导入错误 : No Module Named <parent dir>

python - 验证字节流是否为有效的 UTF-8(或其他编码),无需复制

java - 人物 hell