从PostgreSQL迁移到MySQL时出错[42703]

时间:2018-01-24 19:43:30

标签: mysql sql postgresql mysql-workbench

我在Postgres有一个数据库,我想迁移到MySQL,但每当我进入MySQL Workbench Migration Wizard的逆向工程阶段时,我都会收到错误消息。错误是:

    ERROR: Reverse engineer selected schemas: ProgrammingError("('42703', '[42703] ERROR: column "min_value" does not exist;\nError while executing the query (1) (SQLExecDirectW)')"): error calling Python module function DbPostgresqlRE.reverseEngineer
Failed

完整的错误日志是:

    File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\db_generic_re_grt.py", line 237, in reverseEngineer
    catalog = cls.reverseEngineerCatalog(connection, catalog_name)
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\db_generic_re_grt.py", line 397, in reverseEngineerCatalog
    cls.reverseEngineerSequences(connection, schema)
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\db_postgresql_re_grt.py", line 76, in reverseEngineerSequences
    min_value, max_value, start_value, increment_by, last_value, is_cycled, ncache = cls.execute_query(connection, seq_details_query % (schema.name, seq_name)).fetchone()
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\db_generic_re_grt.py", line 76, in execute_query
    return cls.get_connection(connection_object).cursor().execute(query, *args, **kwargs)
pyodbc.ProgrammingError: ('42703', '[42703] ERROR: column "min_value" does not exist;\nError while executing the query (1) (SQLExecDirectW)')

Traceback (most recent call last):
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\workbench\wizard_progress_page_widget.py", line 192, in thread_work
    self.func()
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\migration_schema_selection.py", line 175, in task_reveng
    self.main.plan.migrationSource.reverseEngineer()
  File "C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\migration.py", line 369, in reverseEngineer
    self.state.sourceCatalog = self._rev_eng_module.reverseEngineer(self.connection, self.selectedCatalogName, self.selectedSchemataNames, self.state.applicationData)
SystemError: ProgrammingError("('42703', '[42703] ERROR: column "min_value" does not exist;\nError while executing the query (1) (SQLExecDirectW)')"): error calling Python module function DbPostgresqlRE.reverseEngineer
ERROR: Reverse engineer selected schemas: ProgrammingError("('42703', '[42703] ERROR: column "min_value" does not exist;\nError while executing the query (1) (SQLExecDirectW)')"): error calling Python module function DbPostgresqlRE.reverseEngineer
Failed

我尝试按照顶部评论here中的说明修改Python脚本,但这并没有阻止错误。有谁知道我怎么解决这个问题?

2 个答案:

答案 0 :(得分:3)

修复文件"C:\Program Files\MySQL\MySQL Workbench 6.3 CE\modules\db_postgresql_re_grt.py"行,第70行更改为

seq_details_query = """SELECT min_value, max_value, start_value, 
increment_by, last_value, cycle as is_cycled, cache_size as cache_value
FROM pg_catalog.pg_sequences
WHERE schemaname = '%s' AND sequencename = '%s' """

答案 1 :(得分:0)

我有PostgreSQL 10.5

已替换为db_postgresql_re_grt.py:80

min_value, max_value, start_value, increment_by, last_value, is_cycled, ncache = cls.execute_query(connection, seq_details_query % (schema.name, seq_name)).fetchone()

具有:

last_value, log_cnt, is_called = cls.execute_query(connection, """SELECT last_value, log_cnt, is_called FROM "%s"."%s" """ % (schema.name, seq_name)).fetchone()
seqrelid, seqtypid, seqstart, seqincrement, seqmax, seqmin, seqcache, seqcycle = cls.execute_query(connection, "select seqrelid, seqtypid, seqstart, seqincrement, seqmax, seqmin, seqcache, seqcycle from pg_sequence where seqrelid = '%s'::regclass" % seq_name).fetchone()
min_value = seqmin
max_value = seqmax
start_value = seqstart
increment_by = seqincrement
is_cycled = seqcycle
ncache = seqcache