X-Original-To: pgsql-www-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C9E719FB2A0 for ; Thu, 3 Aug 2006 04:07:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 61545-01 for ; Thu, 3 Aug 2006 04:06:56 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from service-web.de (p15093784.pureserver.info [217.160.106.224]) by postgresql.org (Postfix) with ESMTP id 953149FB282 for ; Thu, 3 Aug 2006 04:06:57 -0300 (ADT) Received: from [145.228.94.105] (unknown [145.228.94.105]) by service-web.de (Postfix) with ESMTP id 1291020045D; Thu, 3 Aug 2006 09:06:54 +0200 (CEST) Message-ID: <44D1A08C.9090306@wildenhain.de> Date: Thu, 03 Aug 2006 09:06:52 +0200 From: Tino Wildenhain User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: anil maran Cc: pgsql-www@postgresql.org Subject: Re: latin-1 to utf8 in python References: <20060802192612.71752.qmail@web55915.mail.re3.yahoo.com> In-Reply-To: <20060802192612.71752.qmail@web55915.mail.re3.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.135 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/27 X-Sequence-Number: 10418 anil maran schrieb: > postgres takes utf8 > pls help me solve this thanks a lot > some data is in latin-1 so postgres > crashes hm. "crashes" isnt quite correct, it would "bark" or something, however ;) > with > psycopg2.ProgrammingError at /todo/38 > invalid byte sequence for encoding "UTF8": 0x92 > ariable Value > args > ("INSERT INTO xdaad(nt, nn, tadadid, email) VALUES (%s, %s, %s, %s); SELECT > currval('comments_id_seq')", ['co-worker\x92snd I\x92ll get the > .\r\n\r\n \r\n\r\nAeF\r\n\r\n\r\n\r\n \r\n\r\n', '121', '38', '... > @tad.com']) > > Well you either recode in python: latin1string.decode('iso-8859-1').encode('utf-8') or set your client-encoding for postgres, so postgres does the conversion. Look into psycopg api how to do this on connect or just issue: "SET CLIENT_ENCODING TO 'iso-8859-1'" just after connect. Regards Tino Wildenhain