I really hate to be a pain, but I can not get this to work. I have removed the charset=utf8&use_unicode=1 from the connection string amd get the schema using fromDatabase. When I try to insert the string:

Chèrie

it fails at a different location, line 146 of cursors.py of the Mysqldb package.

query = query.encode(charset)

charset is latin1 and it fails with the error:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 36: ordinal not in range(128)

This is where I started looking into unicode, but if there is another way to get past this, please let me know.


Thanks

 Glenn

On Jan 7, 2008 1:05 PM, Oleg Broytmann < phd@phd.pp.ru> wrote:
On Mon, Jan 07, 2008 at 12:56:04PM -0500, Glenn MacGregor wrote:
> Maybe I need to backup at bit. I am somewhat confused at this point. I need
> to insert a string which contains a non-ascii character into my database
> table, that character is Ch0xE9rie. E9 is the hex representation of the
> acute-e. Do I need unicode to do this, do I need to change the charset? What
> are my options?

  In general, you can use unicode, but you don't have to. You are not
obliged to use unicode.
  In this particular case you have a str string from a file in an unknown
charset, certainly not in utf-8, so you cannot use utf-8 as the charset.
Probably for this column you don't need unicode at all.
  Without unicode your options are:

-- use plain strings with StringCol;
-- use binary data with BLOBCol;
-- use complex data with PickleCol.

Oleg.
--
    Oleg Broytmann             http://phd.pp.ru/            phd@phd.pp.ru
          Programmers don't die, they just GOSUB without RETURN.