From: Glenn M. <gle...@gm...> - 2008-01-07 19:00:55
|
I really hate to be a pain, but I can not get this to work. I have removed the charset=3Dutf8&use_unicode=3D1 from the connection string amd get the s= chema using fromDatabase. When I try to insert the string: Ch=E8rie it fails at a different location, line 146 of cursors.py of the Mysqldb package. query =3D 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 t= o get past this, please let me know. Thanks Glenn On Jan 7, 2008 1:05 PM, Oleg Broytmann < ph...@ph...> 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 databas= e > > 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/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |