Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MS SQL to MySQL Transition Using Workbench- Error during reverse engineer selected schemeta

I'm trying to migrate a MS SQL database to MySQL using workbench 6.0 CE. During "reverse engineer selected schemeta" step, I get the "UnicodeDecodeError". I'm wondering how to debug this problem? All the tables name are very straight forward and not using any kind of special characters.

The error log is as below:

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

Thanks for your help. -Deepak

like image 854
Deepak Avatar asked Apr 17 '26 10:04

Deepak


1 Answers

I know is an old issue, but my MySQL Workbench crashed trying to migrate from a SQL Server database for the same reason. I have corrected this problem changing the default encoding to the appropriate one in "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\db_mssql_grt.py" file. I had these two lines (141-142 in my scripts):


    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'))

In my case, SQL Server is using cp1252, so I change utf-16 to cp1252.

like image 141
Rodrigo Avatar answered Apr 19 '26 23:04

Rodrigo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!