I just whipped up this little extension to
MySQLdb/cursors.py today. It automatically
translates strings coming out of MySQL to Unicode
if appropriate. I suspect it's not quite what you'll
want (it does double the number of cursor classes),
but it does give you some code to start with.
Typical usage for people using predominantly
western European languages would be to just pick
the approprite Unicode variant of the various
cursor classes when connecting to the database. For
people who use different encodings than the defaults
listed in UnicodeMixIn.encodings, they can simply
subclass the appropriate cursor class and define
their own list of encodings to try.
The patch is against 0.9.1 but I compared my version
of cursors.py with that in 0.9.2b1 and didn't see
any obvious conflicts.
Log in to post a comment.