Closed robbinonline closed 1 year ago
What's your MySQL connector version?
(venv) ➜ ~ pip install mysql-connector-python
Requirement already satisfied: mysql-connector-python in ./venv/lib/python3.11/site-packages (8.0.33)
Requirement already satisfied: protobuf<=3.20.3,>=3.11.0 in ./venv/lib/python3.11/site-packages (from mysql-connector-python) (3.20.3)
Looks like for some reason
from mysql.connector import CMySQLConnection
works on macOS but not on your specific Linux installation. Oddly enough also the tests made on Ubuntu Linux passed.
I made the import more specific now
from mysql.connector.connection_cext import CMySQLConnection
Would you mind sharing your specific Linux flavor & Python setup?
Fix released in v2.0.2
The error is gone, only a new came up
➜ ~ mysql2sqlite --help
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/mysql/connector/connection_cext.py", line 64, in
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/bin/mysql2sqlite", line 5, in <module>
from mysql_to_sqlite3.cli import cli
File "/usr/lib/python3.11/site-packages/mysql_to_sqlite3/__init__.py", line 4, in <module>
from .transporter import MySQLtoSQLite
File "/usr/lib/python3.11/site-packages/mysql_to_sqlite3/transporter.py", line 17, in <module>
from mysql.connector.connection_cext import CMySQLConnection
File "/usr/lib/python3.11/site-packages/mysql/connector/connection_cext.py", line 85, in <module>
raise ImportError(
ImportError: MySQL Connector/Python C Extension not available (No module named '_mysql_connector')
Hmm, sounds similar to this https://www.reddit.com/r/learnpython/comments/tcngxh/mysql_connectorpython_c_extension_not_available/
Can you re-install the Python MySQL connector using pip
?
pip install --force-reinstall mysql-connector-python
Also, would you mind sharing your specific Linux flavor & Python setup cause it looks like your installation is somehow broken.
Unfortunately, that is not the solution. I try to uninstall, reinstall. When I use it after uninstall I got the error:
ModuleNotFoundError: No module named 'mysql'
and after install the same error.
Python version: 3.11.3 on Home Assistant OS 10.3 I came here after this topic: https://community.home-assistant.io/t/migrating-from-mysql-mariadb-back-to-sqlite/545837/52
The original error is also mentioned there, but also people execute with succes
I've swapped out
from mysql.connector.connection_cext import CMySQLConnection
for
from mysql.connector.abstracts import MySQLConnectionAbstract
and will release it in v2.0.3.
Home Assistant OS 10.3
Ah, so that could be the issue. I am only testing against Ubuntu and have no clue what this Linux flavor is.
Anyhow, you can always use the v1 branch. In v2 I threw all of the deprecated old code out.
Fix released in v2.0.3.
Use the v1 branch was the trick, now everything works fine and migration was successful :)
Do you mind trying it with v2.0.3? I'm curious if it will work.
Yes it works now with v2.0.3 at least the command: mysql2sqlite --help I have not done the migration again, but I assume that it will work now.
Cool. It's interesting that this particular Linux distro doesn't support the MySQL C extension.
I try install this on my linux vm but I get this error when I try to run mysql2sqlite
I have installed it like this: