3

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

5
  • That sounds very much like invalid content. The utf16 conversion did not work because of data that cannot be decoded. So check that particular column to see what it contains and maybe do some fixes to make it convertible. Commented Mar 28, 2014 at 7:54
  • Thanks for responding Mike. As far as name of all tables and columns are concern, those doesn't use any such characters, But I know that there are data in various tables having double bytes characters such as chinese, japanese language characters. How do I Know that which table/column is creating problem? Commented Mar 28, 2014 at 8:09
  • Hmm, good question. I'd expect the error message to contain the table (and maybe even the column) in question. If that is not the case you can try to find the offending table at least by including one table after the other in the conversion process. Commented Mar 28, 2014 at 8:12
  • There are around 400 tables so it may not be feasible going that way. I'm wondering if the "reverse..." step really look into the data during that time? Also, if it is an issue with the data, will there be eventually a way to move data to MySQL (If I think of creating exact same database in MySQL first)? Commented Mar 28, 2014 at 9:08
  • I have this to, should not Migration Workbench be able to handle any SQL Server object. I thought it was for migrating. Pretty useless product. Commented Jul 25, 2014 at 12:46

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Worked for me. MySQL Workbench version 8.0.23; SQL Server 2012 (SP1) - 11.0.3128.0 (X64)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.