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

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

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.

Related

UnicodeEncodeError occurs when attempting to migrate MSSQL data to MariaDB with MySQL Workbench

I'm trying to move data from SQL Server to MariaDB using MySQL Workbench.
I installed it as 8.0.27 version at first, and after the problem occurred, I downgraded it to 8.0.26 version, but the problem was not solved.
I'm confused whether it's a problem with the data you're trying to move or something that's happening in MySQL Workbench.
I tried googling, but there was a similar phenomenon, but I couldn't find an answer.
https://bugs.mysql.com/bug.php?id=105772
Can you give me some advice?
thanks you.
------------------------------------------------------------------ Starting... Create Script File...
Traceback (most recent call last): File "C:\Program
Files\MySQL\MySQL Workbench 8.0
CE\workbench\wizard_progress_page_widget.py", line 71, in run
self.func() File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\migration_schema_creation.py", line 188, in
_create_script_task
self.main.plan.createTargetScript(self.main.plan.state.objectCreationParams["CreateSQLFile"])
File "C:\Program Files\MySQL\MySQL Workbench 8.0
CE\modules\migration.py", line 527, in createTargetScript
grt.modules.DbMySQLFE.createScriptForCatalogObjects(path, self.migrationTarget.catalog, self.state.objectCreationParams)
SystemError: UnicodeEncodeError("'charmap' codec can't encode
characters in position 99-104: character maps to "): error
calling Python module function DbMySQLFE.createScriptForCatalogObjects
ERROR: Error during Create Script File: UnicodeEncodeError("'charmap'
codec can't encode characters in position 99-104: character maps to
"): error calling Python module function
DbMySQLFE.createScriptForCatalogObjects ERROR: Exception in task
'Create Script File': SystemError('UnicodeEncodeError("'charmap'
codec can't encode characters in position 99-104: character maps to
"): error calling Python module function
DbMySQLFE.createScriptForCatalogObjects')
Failed
enter image description here
If you are seeing \uFFFD, that is the REPLACEMENT CHARACTER - - �
It means that the data was already corrupted beyond repair. Go back a step in the process of the data to see what first led to it.
See also "black diamond" in Trouble with UTF-8 characters; what I see is not what I stored to find some ways that it can occur purely in MySQL. However, it sounds like SQL Server created it; I think the problem is back there.
Fetch the hex for any characters involved, noting that \uFFDD (UTF-8 hex: EFBFBD) is after things are already corrupted.
In UTF-8 (MySQL's utf8 or utf8mb4), Hex EAB0zz through ED9Ezz is used for Hangul (Korean). For example, 박상우 is hex EBB095 EC8381 EC9AB0 (minus the spaces).

Saltstack smtp.send_msg returning with attribute error

I set up a beacon that tracks disk usage on all the Ubuntu Server 16.04 minions on Ubuntu Server 16.04. We wanted a reactor that emails us when disk space reaches a certain point. This question focuses on the master's ability to send an email. When I run the following command on the salt-master:
sudo salt-call smtp.send_msg 'email#email.com' 'Test message 3' subject='Test subject 3' profile='smtp-default'
I get the following result:
[ERROR ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
Traceback (most recent call last):
File "/usr/bin/salt-call", line 11, in <module>
salt_call()
File "/usr/lib/python2.7/dist-packages/salt/scripts.py", line 391, in salt_call
client.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/call.py", line 58, in run
caller.run()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 134, in run
ret = self.call()
File "/usr/lib/python2.7/dist-packages/salt/cli/caller.py", line 204, in call
ret['return'] = func(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/salt/modules/smtp.py", line 95, in send_msg
server = creds.get('smtp.server')
AttributeError: 'str' object has no attribute 'get'
This is my salt --versions-report output of the master that returns the error:
Salt Version:
Salt: 2017.7.1
Dependency Versions:
cffi: 1.10.0
cherrypy: unknown
dateutil: 2.4.2
docker-py: Not Installed
gitdb: 0.6.4
gitpython: 1.0.1
ioflo: Not Installed
Jinja2: 2.8
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: Not Installed
Mako: 1.0.3
msgpack-pure: Not Installed
msgpack-python: 0.4.6
mysql-python: Not Installed
pycparser: 2.18
pycrypto: 2.6.1
pycryptodome: Not Installed
pygit2: Not Installed
Python: 2.7.12 (default, Nov 19 2016, 06:48:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.2.0
RAET: Not Installed
smmap: 0.9.0
timelib: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
System Versions:
dist: Ubuntu 16.04 xenial
locale: UTF-8
machine: x86_64
release: 4.4.0-93-generic
system: Linux
version: Ubuntu 16.04 xenial
I have uninstalled and reinstalled the salt-master and salt-minion and I have updated Python and the salt-master. I also created another salt-master and it ran into the same problem. What is the fix or solution to this?
I have discovered that the error has nothing to do with the installed Python libraries or if my system is updated or not. I found that I did not have an SMTP server set up and that I need to create an SMTP mail server or have an accessible SMTP mail server in order to send emails as notifications of the reactor system. I discovered that the solution was to set up an SMTP mail server and then create a .conf file in the /etc/salt/minion.d directory that referenced an SMTP mail server like so:
smtp-default:
smtp.sender: mail#example.com
smtp.server: 0.0.0.0
smtp.tls: false
After creating a .conf file similar to the one above and the profile of the salt-call command referring to the function declaration of the state file, I was able to send emails to the desired address.

mysql database data import error

When I go to import data into mysql, using the wizard, from a csv file it gives me this error :
Starting...
Prepare Import...
Prepare Import done
Import data file....
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\sqlide_power_import_wizard.py", line 125, in start_import
retval = self.module.start(self.stop)
File "C:\Program Files\MySQL\MySQL Workbench 6.3
CE\modules\sqlide_power_import_export_be.py", line 271, in start
ret = self.start_import()
File "C:\Program Files\MySQL\MySQL Workbench 6.3
CE\modules\sqlide_power_import_export_be.py", line 408, in
start_import
if not self.prepare_new_table():
File "C:\Program Files\MySQL\MySQL Workbench 6.3
CE\modules\sqlide_power_import_export_be.py", line 237, in
prepare_new_table
self._editor.executeManagementCommand(""" CREATE TABLE %s (%s)""" % (self._table_w_prefix, ", ".join(["%s %s" % (col['name'],
col["type"]) for col in self._mapping])), 1)
DBError:
("Incorrect column name ''", 1166)
ERROR:
Import data file: ("Incorrect column name ''", 1166)
Failed
Edit: I forgot to add an actual question to this, can someone help me in solving this error?
Was struggling with the same error. The solution is quite simple though.
In the .csv file from which you were trying to import data from, if you look closely the field names and rows are in order such as:
;"created_at";"updated_at";"country_code";"mobile_number";"site_context";"country";"user_id";"uuid"
1;1547471922220;1547471922220;"91";"9711843454";"rexmonster";"IN";0;""
2;1547471959995;1547471959995;"91";"971184";"rexmonster";"IN";0;""
Here, the first col. name is null which is creating the error.
All you need to do is just provide any column name at that place
e.g.:
"SerialNum";"created_at";"updated_at";"country_code";"mobile_number";"site_context";"country";"user_id";"uuid"
1;1547471922220;1547471922220;"91";"9711843454";"rexmonster";"IN";0;""
2;1547471959995;1547471959995;"91";"971184";"rexmonster";"IN";0;""
Boom you are done.
The import will work smooth now!
I had the same issue, and my problem was that there were spaces in the headers of my csv file. Simply open the csv with a text editor, and remove the spaces.

Tryton ERP MySQL installation

I'm trying to install Tryton ERP with MySQL as the database. It's not quite clear what you are meant to do.
From the config documentation you simply supply the uri to the database under the [database] section:
[database]
uri = mysql://user:pass#localhost:3306
However running trytond -v -c /home/user/.config/tryton/3.8/tryton.conf does not seem to get it working. When trying to access the 127.0.0.1:8050 where I've got Tryton running, I simply get 127.0.0.1 - - [23/Nov/2015 16:55:10] code 404, message File not found
One would assume, Tryton either installs the database on its own or you need to create yourself somehow but I didn't see any documentation surrounding that.
I've also trying adding a database through the Tryton GUI, it encounters the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tryton/gui/window/dbcreate.py", line 65, in server_change
common.refresh_langlist(self.combo_language, host, port)
File "/usr/local/lib/python2.7/dist-packages/tryton/common/common.py", line 253, in refresh_langlist
lang_list = rpc.db_exec(host, port, 'list_lang')
File "/usr/local/lib/python2.7/dist-packages/tryton/rpc.py", line 57, in db_exec
result = getattr(connection.common.db, method)(None, None, *args)
File "/usr/lib/python2.7/xmlrpclib.py", line 1233, in __call__
return self.__send(self.__name, args)
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 271, in __request
verbose=self.__verbose
File "/usr/lib/python2.7/xmlrpclib.py", line 1273, in request
return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python2.7/xmlrpclib.py", line 1306, in single_request
return self.parse_response(response)
File "/usr/lib/python2.7/xmlrpclib.py", line 1482, in parse_response
return u.close()
File "/usr/local/lib/python2.7/dist-packages/tryton/jsonrpc.py", line 134, in close
return json.loads(self.data, object_hook=object_hook)
File "/usr/lib/python2.7/dist-packages/simplejson/__init__.py", line 505, in loads
return cls(encoding=encoding, **kw).decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python2.7/dist-packages/simplejson/decoder.py", line 389, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 1 column 2 (char 1)
I've got the prerequisites installed that were listed here and MySQL-python package installed, should there be anything else?
You should create a database on MySQL with it's own tools. Once the database is created you must initialize it using the following command:
trytond -c <config_file> -d <database name> --all
See for complete reference:
http://doc.tryton.org/3.8/trytond/doc/topics/setup_database.html#topics-setup-database.
Once finished, the server will ask for an admin password. Once entered you can conect using the tryton client with the admin user and the entered password.
In order to access tryton from web client you must install and configure the sao web interface, that can be found on:
https://www.npmjs.com/package/tryton-sao

MySQL Connector/Python 1.0.7 on OSX 10.8 not getting a cursor

Here's a skeleton of my Python code:
import mysql.connector
sql = mysql.connector.connect(user='user', password='pwd',
host='127.0.0.1', database='my_db')
cursor = sql.cursor()
Yields this mysterious error message:
Traceback (most recent call last):
File "pyscript_v2.py", line 36, in
cursor = sql.cursor()
file "/Library/Python/2.7/site-packages/mysql/connector/connection.py", line 1063, in cursor raise errors.OperationalError("MySQL Connection not available.")
mysql.connector.errors.OperationalError: MySQL Connection not available.
My Google-fu is failing to dig anything up, am I missing something in setting up my MySQL DB connection in Python?
I'm running Python 2.7.2 on OS X 10.8.2, and am using MySQL Connector/Python 1.0.7.
Following link has explanation and possible solution.
http://bugs.mysql.com/bug.php?id=67649