Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!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.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; '*not*': 0.07; "'localhost',": 0.16; "'w',": 0.16; 'charset': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'michael.': 0.16; 'statements,': 0.16; 'subject:issue': 0.16; 'sys.stdout': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'error': 0.23; 'tells': 0.24; 'unicode': 0.24; 'script': 0.25; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'host': 0.29; 'specified': 0.30; "skip:' 10": 0.31; 'subject: (': 0.35; 'something': 0.35; 'but': 0.35; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'subject: ': 0.61; 'here': 0.66; 'header:Reply-To:1': 0.67; 'line,': 0.68; 'reply- to:no real name:2**0': 0.71; 'reply-to:addr:python.org': 0.84 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=KrN0hwmN c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=oyR3mlnJdzkA:10 a=Xy1Zd51sZcEA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=sNwuKyLBXKYA:10 a=leu3Kt0pwhkIbG_q9HAA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett:2500 Date: Tue, 28 May 2013 17:26:07 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Encodign issue in Python 3.3.1 (once again) References: <7823093c-2c07-4fa0-ae97-960c62f8ff9d@googlegroups.com> <69f5q8hkra42rvpfmbng4f0airgikqf5js@4ax.com> <9560d43f-8100-4914-9a71-c30ab479ec35@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: python-list@python.org 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: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369758543 news.xs4all.nl 15963 [2001:888:2000:d::a6]:57507 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46307 On 28/05/2013 17:00, Νίκος Γκρ33κ wrote: > I do not know here to find connections.py Michael. > > But i do not understand since iam suing the following 2 statements, why a unicode error remains. > > #needed line, script does *not* work without it > sys.stdout = os.fdopen(1, 'w', encoding='utf-8') > > # connect to database > con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'myself', passwd = 'mypass', init_command='SET NAMES UTF8' ) > cur = con.cursor() > > Shall i chnage the connector form 'pymysql' => 'MySQLdb' ? > A quick look at the documentation tells me that the charset can be specified in the 'connect' call, something like this: con = pymysql.connect( db = 'pelatologio', host = 'localhost', user = 'myself', passwd = 'mypass', init_command='SET NAMES UTF8', charset = 'utf-8' )