Menu

UnicodeDecodeError: '

Help
SzE
2006-10-22
2012-09-19
  • SzE

    SzE - 2006-10-22

    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

     
    • Andy Dustman

      Andy Dustman - 2006-10-27

      Try 1.2.2b2 instead.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.