我正在尝试使用workbench 6.0 CE将MS SQL数据库迁移到MySQL。在“逆向工程选择方案”步骤中,我得到“UnicodeDecodeError”。我想知道如何调试这个问题?所有表格名称都很直接,不使用任何特殊字符。
错误日志如下:
Starting...
Connect to source DBMS...
- Connecting...
Connecting to Mssql@DRIVER=SQL Server;SERVER=localhost\instance1...
Opening ODBC connection to DRIVER={SQL Server};SERVER=localhost\instance1;DATABASE={};UID=sa;PWD=XXXX;...
Connected
Connect to source DBMS done
Reverse engineer selected schemata....
Reverse engineering dbo from testdb
- Reverse engineering catalog information
- Reverse engineering User Data Types...
- Preparing...
- Gathered stats for dbo
Reverse engineering 379 tables from dbo
Traceback (most recent call last):
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\modules\db_mssql_grt.py", line 384, in reverseEngineer
reverseEngineerTables(connection, schema)
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\modules\db_mssql_grt.py", line 545, in reverseEngineerTables
table_names = [(row[0], row[1]) for row in execute_query(connection, query % schema.name) ]
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\modules\db_mssql_grt.py", line 130, in <lambda>
con.add_output_converter(-150, lambda value: value if value is None else value.decode('utf-16'))
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\Python\Lib\encodings\utf_16.py", line 16, in decode
return codecs.utf_16_decode(input, errors, True)
**UnicodeDecodeError: 'utf16' codec can't decode byte 0x73 in position 54: truncated data**
Traceback (most recent call last):
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\workbench\wizard_progress_page_widget.py", line 192, in thread_work
self.func()
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\modules\migration_schema_selection.py", line 160, in task_reveng
self.main.plan.migrationSource.reverseEngineer()
File "C:\Program Files (x86)\MySQL\MySQL Workbench CE 6.0.8\modules\migration.py", line 353, in reverseEngineer
self.state.sourceCatalog = self._rev_eng_module.reverseEngineer(self.connection, self.selectedCatalogName, self.selectedSchemataNames, self.state.applicationData)
SystemError: UnicodeDecodeError("'utf16' codec can't decode byte 0x73 in position 54: truncated data"): error calling Python module function DbMssqlRE.reverseEngineer
ERROR: Reverse engineer selected schemata: UnicodeDecodeError("'utf16' codec can't decode byte 0x73 in position 54: truncated data"): error calling Python module function DbMssqlRE.reverseEngineer
Failed
感谢您的帮助。 -Deepak
答案 0 :(得分:1)
我知道这是一个老问题,但是出于相同的原因,我的MySQL Workbench在尝试从SQL Server数据库迁移时崩溃了。我已经解决了将默认编码更改为“ C:\ Program Files \ MySQL \ MySQL Workbench 8.0 CE \ modules \ db_mssql_grt.py”文件中的相应编码的问题。我有这两行(我的脚本中为141-142):
con.add_output_converter(-150, lambda value: value if value is None else value.decode('utf-16'))
con.add_output_converter(0, lambda value: value if value is None else value.decode('utf-16'))
在我的情况下,SQL Server使用的是cp1252,因此我将utf-16更改为cp1252。