Bug #117302 mysql-connector-python raises an import error on Linux distributions without GLIBC
Submitted: 27 Jan 15:36 Modified: 27 Jan 16:07
Reporter: Ittai D Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / Python Severity:S2 (Serious)
Version: OS:Linux (Alpine and others)
Assigned to: CPU Architecture:Any

[27 Jan 15:36] Ittai D
Description:
The mysql_connector_python-9.2.0-py2.py3-none-any.whl (and other versions of the "generic" wheel) is subtly broken- it's missing the implementation for `_mysql_connector`, the c extension. This is likely by design- since there's no way to create a generic wheel for native code- however, the existence of this wheel and the lack of a source distribution means this package cannot be relied upon- installing it on an alpine docker exposes a different API when compared to an ubuntu one, for example.

How to repeat:
Easiest way to reproduce is with an alpine docker:

```
docker run --rm -it python:3.13-alpine sh

pip install mysql-connector-python
python -c "import mysql.connector.cursor_cext"
```

Suggested fix:
A source distribution can instead be supplied, which will allow pip to build the wheel with the C extension in the case GLIBC is missing. Additionally, the c extension should be feature-gated, to turn reliance on it to a installation an error instead of a runtime error in the case it is missing.
[27 Jan 15:57] MySQL Verification Team
HI Mr. D,

Thank you for your bug report.

However, this is a forum for the bugs with fully repeatable test cases. 

A test case should consists of a set of SQL statements, all relevant code and actions that lead to the problem reported.

However, you have not supplied such a test case.

Furthermore, we do not understand what you are reporting here .....

Can't repeat.
[27 Jan 16:04] Ittai D
I'm reporting an issue with the mysql connector for python, specifically its lack of consistency with different linux distributions- for example, on alpine linux, certain imports and functionalities cause a runtime error, while on ubuntu they do not.

This cannot be show using SQL for this is not an issue with the MySQL server; this is an issue with the supplied connector library, and so my reproduction constructs (using an alpine docker) an environment in which said python connector misbehaves.
[27 Jan 16:07] Ittai D
For the sake of other looking into why their python application has an error when running on alpine- the exact error string is:

```
ModuleNotFoundError: No module named '_mysql_connector'
```
[27 Jan 20:17] Daniƫl van Eeden
You could try `use_pure=True`.

https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html

(Note: I'm not working for Oracle)