registry team mailing list archive
-
registry team
-
Mailing list archive
-
Message #26160
[Bug 57067] Re: UnicodeDecodeError: 'ascii' codec can't decode certain bytes
I stumbled upon Toby Smithe's problem (3 years after he did) :) It's not
a bug, but rather a sneaky configuration problem. Turns out the client,
by default, connects to the server using ascii mode...
I solved it with this:
http://bytes.com/topic/python/answers/630063-mysql-insert-unicode-problem
Short summart, check this:
mysql> SHOW VARIABLES LIKE "character_set%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
That latin1 is the problem. To change it, when you instantiate your connection with MySQLdb, make sure to attach the last two parameters here:
conn = MySQLdb.connect(host=host, user=user, passwd=passwd, db=db, use_unicode = True, charset = "utf8")
That did it for me!
--
UnicodeDecodeError: 'ascii' codec can't decode certain bytes
https://bugs.launchpad.net/bugs/57067
You received this bug notification because you are a member of Registry
Administrators, which is the registrant for Debian.