Re: Character Encoding Question

From: Don Parris <parrisdc(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: Character Encoding Question
Date: 2013-03-28 17:38:57
Message-ID: CAJ-7yonccxZTKRdAc_f4GPp2Znk1aBnfyHzb+xQCrwi_Xeu1aQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

For the list:

Here is the result of the query you suggested:

>>> cur = con.cursor()
>>> cur.execute("show client_encoding")
>>> print(cur.fetchone()[0])
SQL_ASCII

I created the DB in postgresql using the following command:
CREATE DATABASE mydb
WITH TEMPLATE template0 ENCODING 'UTF8';

Although I cannot now recall my reason for doing so, there *is* a reason
why I'm using this approach. :-/ I should have said "why" in my comments!

On Thu, Mar 28, 2013 at 12:41 PM, Daniele Varrazzo <
daniele(dot)varrazzo(at)gmail(dot)com> wrote:

> On Thu, Mar 28, 2013 at 4:34 PM, Don Parris <parrisdc(at)gmail(dot)com> wrote:
> > Thanks Daniele,
> >
> > I'm using psycopg 2.4.5 with Python 3.2.3 on Kubuntu 12.10.
> >
> > This is the connection encoding based on a quick check at the Python
> > console:
> >>>>print(con.encoding)
> > SQLASCII
>
> In this case it's natural that you get an error on decode. But is it
> really the database encoding? What does this query say:
>
> cur = con.cursor()
> cur.execute("show client_encoding")
> print cur.fetchone()[0]
>
>
> > I honestly don't know where the error actually is - not a very advanced
> > programmer by any means. All I really know is that the program breaks
> when
> > I use fetchall(), but it works with fetchone() and fetchmany(). It could
> > have something to do with the way my main program module imports the
> module
> > that calls the function, for all I know. Here is the traceback:
>
> I'll try to load your dataset and play with it, thank you.
>
> -- Daniele
>

--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
http://dcparris.net/
<https://www.xing.com/profile/Don_Parris><http://www.linkedin.com/in/dcparris>
GPG Key ID: F5E179BE

In response to

Browse psycopg by date

  From Date Subject
Next Message Don Parris 2013-03-28 20:49:13 Re: Character Encoding Question
Previous Message Daniele Varrazzo 2013-03-28 17:30:00 Re: Character Encoding Question