使用mysqldump将mysql迁移到postgres

时间:2019-05-16 12:04:02

标签: python mysql postgresql migration

我已从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"\\")

0 个答案:

没有答案