迁移mysql到postgres用mysqldump

2024-10-05 17:56:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经从MySQL中删除了:

mysqldump --compatible=postgresql --default-character-set=utf8 \
-r databasename.mysql -u root databasename

我有python脚本来创建与postgres兼容的SQL,但它给出了以下错误:

parse(sys.argv[1], sys.argv[2])
  File "test.py", line 71, in parse
    line = line.decode("utf8").strip().replace(r"\\", "WUBWUBREALSLASHWUB").replace(r"\'", "''").replace("WUBWUBREALSLASHWUB", r"\\")
  File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf4 in position 679: invalid continuation byte

在以下位置显示错误:

line = line.decode("utf8").strip().replace(r"\\", "WUBWUBREALSLASHWUB").replace(r"\'", "''").replace("WUBWUBREALSLASHWUB", r"\\")

Tags: nameinpyparse错误syslineutf8