Encodign issue in Python 3.3.1 (once again)

Michael Torrie torriem at gmail.com
Mon May 27 10:42:56 EDT 2013


On 05/26/2013 11:06 PM, Νίκος Γκρ33κ wrote:
> But iu have it set up for 'utf-8' as seen in this statement.
> 
> con = pymysql.connect( db = 'metrites', host = 'localhost', user = 
> 'me', passwd = 'somepass', charset='utf-8', init_command='SET NAMES UTF8' ) 

That might not help... see below.

> 
> Yoiu mean i shoudl chnag eit to greek isoo= (iso-8859-7)
> but then i store english names and greek names as well, so it has to be a utf-8.

Right.  UTF-8 is the encoding you want.

I think your problem is that when the MySQL database was created, it was
not created using the UTF-8 mode, but rather latin-1 (despite your
init_command which has nothing to do with database creation).  You'll
want to recreate the database and make double sure you've selected the
right character set and collation:

http://dev.mysql.com/doc/refman/5.0/en/charset-applications.html

At least that should be your first step in debugging this problem.

If the database is indeed utf-8, then you can move on to debugging why
the python code is choosing latin-1 to encode your query string.

That's my two-cents for today.



More information about the Python-list mailing list