[Zope-DB] Re: ZMySQLDA and utf-8

Michal Kurowski mkur at poczta.gazeta.pl
Tue Mar 1 04:39:25 EST 2005

Wolfram Kraus [kraus at hagen-partner.de] wrote:
> Python 2.3.4 - Zope 2.7.4 - MySQLdb 1.2.0 - ZMySQLDA 2.0.8 or 2.0.9b2
> How do I set ZMySQLDA to permanently use utf-8 as client character set?
> When I insert the line "self.db.query('set character set utf8')" in 
> db.DB.__init__() everything works fine ("show variables like '%char%'" 
> in the test-tab of ZMySQLDA) until I restart MySQL, which resets the 
> client character set to latin-1. The only solution to set the character 
> set permanently is to do this in _begin().
> Is this recommended or is there another solution?

No, only two hacks ;-)

1) the official one:

generate or edit the "sitecustomize" file (usually
"/usr/local/lib/python2.3/sitecustomize.py" or something similar):

import sys

2) the real hack ;-)

there's undocumented parameter for ZMySQLdb connection string - 
just add "unicode=1" at the end of it 

You'll have to find out which one of those will work for you ;-)
Have luck,

Michal Kurowski
<mkur at poczta.gazeta.pl>

More information about the Zope-DB mailing list