With MySQLdb 1.2.1 + Python 2.5 + Mysql 5.0.x on Windows, when executing a sql command like
INSERT INTO sometable SET somefield = 'somevalue'
and 'somevalue' contains non-ascii (i.e. cebtral-european) character, get the error
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 146, in execute
query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xaa in position 35: ordinal not in range(128)
Notes:
1. The server is started with settings (in my.ini):
character-set-server = latin2
collation-server = latin2_general_ci
skip-character-set-client-handshake
2. Altrough this, the connection's character_set_name() returns 'latin1'
3. Tried
conn = MySQLdb.connect(host='localhost', user='root',charset='latin2', use_unicode = True, read_default_file='c:/WINDOWS/SYSTEM/my.ini') then the above insert statement -- the same error
What to do?
Thanks
Endre
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello
With MySQLdb 1.2.1 + Python 2.5 + Mysql 5.0.x on Windows, when executing a sql command like
INSERT INTO sometable SET somefield = 'somevalue'
and 'somevalue' contains non-ascii (i.e. cebtral-european) character, get the error
File "C:\Python25\Lib\site-packages\MySQLdb\cursors.py", line 146, in execute
query = query.encode(charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xaa in position 35: ordinal not in range(128)
Notes:
1. The server is started with settings (in my.ini):
character-set-server = latin2
collation-server = latin2_general_ci
skip-character-set-client-handshake
2. Altrough this, the connection's character_set_name() returns 'latin1'
3. Tried
conn = MySQLdb.connect(host='localhost', user='root',charset='latin2', use_unicode = True, read_default_file='c:/WINDOWS/SYSTEM/my.ini') then the above insert statement -- the same error
What to do?
Thanks
Endre
Try 1.2.2b2 instead.