Re: psycopg2+postgres check default charset of db or table

From: Joe Abbate <jma(at)freedomcircle(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Re: psycopg2+postgres check default charset of db or table
Date: 2012-04-19 00:30:05
Message-ID: 4F8F5C8D.3050303@freedomcircle.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 04/18/2012 08:12 PM, Peter Irbizon wrote:
> I am using python 2.7 and psycopg2. How could I find out default charset
> used by database? I would like to check it and then according to used
> charset decode returned strings.
>
> I tried "select rdb$character_set_name from rdb$database" but it
> seems it doesn't work for postgres. thank you

"SHOW server_encoding" will show the character encoding after you
connect. "SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE
datname = %(dbname)s" can be used to find out the encoding before
connecting (connecting to the postgres db instead).

Joe

In response to

Browse psycopg by date

  From Date Subject
Next Message Russ Neufeld 2012-04-30 21:29:48 Strange slowness
Previous Message Peter Irbizon 2012-04-19 00:12:50 psycopg2+postgres check default charset of db or table