MySQL Forums
Forum List  »  Connector/Python

Re: Confused about UTF8
Posted by: Huu Da Tran
Date: March 27, 2008 08:16AM

The thing is, MySQL may know that the field is in UTF-8, but your mysql client may not know how to display it on your term. Just make sure when you enter you mysql prompt to set your charset.
$ mysql
mysql> charset utf8
mysql> show variables like '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       | 
| character_set_connection | utf8                       | 
| character_set_database   | utf8                       | 
| character_set_filesystem | binary                     | 
| character_set_results    | utf8                       | 
| character_set_server     | utf8                       | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+

If at this moment, you still get a wrong display, more investigation is required.

BTW, you shoult let MySQLdb do escape your stuff, something like:
name = u'Angélique Kidjo'
sortname = u'Kidjo, Angélique'
cmd = """INSERT INTO artist (name, sortname) values (%s, %s)"""
cursor.execute(cmd, (name, sortname))
It won't change anything in this precise case, but in future...

Hope this helps,
H.

Options: ReplyQuote


Subject
Written By
Posted
March 27, 2008 04:19AM
Re: Confused about UTF8
March 27, 2008 08:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.