tk0miya / testing.postgresql

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

client encoding

nbonnotte opened this issue · comments

How can I specify what the default client encoding should be?

I have tests that fail on a Jenkins server because the client encoding is SQLASCII instead of UTF8...

Ok, I can just specify conn.set_client_encoding('UTF-8') with all my connections, but would it not be possible to have a correct default client encoding?

The database encoding is used for the client encoding by default.
http://www.postgresql.org/docs/9.5/static/runtime-config-client.html#GUC-CLIENT-ENCODING

So you can change it using initidb_args::

>>> from testing.postgresql import Postgresql
>>> import psycopg2
>>> pgsql = Postgresql(initdb_args='-E=EUC_JP --locale=ja_JP.eucJP -U postgres -A trust')
>>> c = psycopg2.connect(**pgsql.dsn())
>>> c.encoding
'EUCJP'

Thanks,

Now, I close this issue.
If you still have any problem, please reopen again.