New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
non-ASCII field name can be used only with utf-8 connections #210
Comments
Encodings other than UTF-8 is not tested, maintained. |
BTW, how can I reproduce it? |
Note that my terminal encoding is utf-8:
So, regardless connection encoding, column name is arbitrary bytes. |
Well it would be interesting to see what happens when you try to query your nonascii_column table with mysqlclient-python. Here are the result of my test with a utf-8 terminal :
We can see that the column is stored as UTF-8. Now in python :
Here we see that the python client sees it at latin-1 |
Using the module with a latin-1 connection I get this Exception :
Looking at _mysql.c, I found out the problem is on line 1265 :
t = Py_BuildValue("(siiiiii)",
In the format string, the s character is interpreted by the python 2 API as an encoded string whereas for python 3 it is interpreted as a wish to decode into a string using utf-8.
Therefore, for python 3 the 's' should be replaced by a 'y' so we will get back a python bytes object. We could then decode this byte python side where we know the encoding used by the database connection.
The text was updated successfully, but these errors were encountered: