Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #64895

Re: Enable unicode

References <CA+FnnTw7aXrBT2kaNDrg9V7Go7NB1M_CxDRw-77MBzXNQiovhg@mail.gmail.com>
Date 2014-01-28 19:35 +1100
Subject Re: Enable unicode
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.6059.1390898159.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Jan 28, 2014 at 7:26 PM, Igor Korot <ikorot01@gmail.com> wrote:
> Hi, ALL,
> In here: http://stackoverflow.com/questions/21397035/set-utf8-on-mysql,
> I got a suggestion to enable "use_unicode".
> Problem is I'm developing on Windows and it's not that I can recompile
> my python.
> I'm using Python2.7 on Windows XP.
>
> Any pointer on how do I enable "use_unicode"?

Before you go any further: MySQL has a broken interpretation of "utf8"
that allows only a subset of the full Unicode range. Instead, use
"utf8mb4", which is what the rest of the world calls UTF-8. As far as
I know, you can just switch in utf8mb4 everywhere that you're
currently using utf8 and it'll work.

According to [1] the use_unicode flag is a keyword parameter to
connect(). As much as possible, I'd recommend using those parameters
rather than explicitly executing SQL statements to reconfigure the
connection - it's clearer, and the local client might want to
reconfigure itself in response to the change too.

Be aware that MySQL has a number of issues with Unicode and sorting
(or at least, it did the last time I checked, which was a while ago
now), not to mention other problems with its default MyISAM format.
You may want to consider PostgreSQL instead.

ChrisA

[1] http://mysql-python.sourceforge.net/MySQLdb.html

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Enable unicode Chris Angelico <rosuav@gmail.com> - 2014-01-28 19:35 +1100

csiph-web