Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'url:sourceforge': 0.03; 'broken': 0.04; 'parameters': 0.04; 'explicitly': 0.05; 'postgresql': 0.07; 'parameter': 0.09; 'statements': 0.09; 'subset': 0.09; 'cc:addr:python-list': 0.11; 'jan': 0.12; 'windows': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'igor': 0.16; 'now),': 0.16; 'range.': 0.16; 'reconfigure': 0.16; 'sorting': 0.16; 'subject:unicode': 0.16; 'utf8': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'possible,': 0.19; 'cc:addr:python.org': 0.22; 'instead.': 0.24; 'pointer': 0.24; 'unicode': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'mention': 0.26; 'switch': 0.26; 'developing': 0.27; 'header :In-Reply-To:1': 0.27; 'rest': 0.29; '[1]': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'too.': 0.31; 'everywhere': 0.31; 'python2.7': 0.31; 'allows': 0.31; 'ago': 0.33; "i'd": 0.34; 'problem': 0.35; 'connection': 0.35; 'received:google.com': 0.35; 'executing': 0.36; 'format.': 0.36; 'keyword': 0.36; 'hi,': 0.36; 'problems': 0.38; 'pm,': 0.38; 'rather': 0.38; 'itself': 0.39; 'according': 0.40; 'how': 0.40; 'full': 0.61; "you're": 0.61; 'here:': 0.62; 'world': 0.66; 'default': 0.69; 'recompile': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=f4w7ZZAq6XTgLA0HUPlipF5pfzd9hMTIeWVBMmEKGTg=; b=wKsrO4dHUHPA/7/qvTf1a1b7GWStMkQk7uxXzxk4UG00EJ9Xc19nfXjDVd3D/1JjZk XQkOnk5yUiVI6QaHHvH/aWDu4Z49MskSXN3GgpBMxmCIWcXDVmC4GkIAZpvqv7+1mNbh xu44gZ2wzEzPO+tQ4UowPmbmN1S2fKPAdMwK8NhJJqeT/T/QNchpZkOFZiI3cM9HcbaP RHDk/xTp0Y4vj785WRPOXZNhCoEOJ5rUO9yIaIeJCfuUewui/uDWMb73lq0o0qqbzyUf Wf5t4cz1wt2v7R9ateeqdTERWnz1maiRRAbi1T3/UBdJ789bP9g6hs1UKK4g612uZhrv 9Huw== MIME-Version: 1.0 X-Received: by 10.66.129.133 with SMTP id nw5mr271565pab.98.1390898149504; Tue, 28 Jan 2014 00:35:49 -0800 (PST) In-Reply-To: References: Date: Tue, 28 Jan 2014 19:35:49 +1100 Subject: Re: Enable unicode From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390898159 news.xs4all.nl 2836 [2001:888:2000:d::a6]:44252 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64895 On Tue, Jan 28, 2014 at 7:26 PM, Igor Korot 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