Re: Using context managers for connections/cursors - cursors are closed, connections are not?

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: Using context managers for connections/cursors - cursors are closed, connections are not?
Дата
Msg-id 20131127111955.GL5031@hermes.hilbert.loc
обсуждение исходный текст
Ответ на Using context managers for connections/cursors - cursors are closed, connections are not?  (Victor Hooi <victorhooi@yahoo.com>)
Список psycopg
On Wed, Nov 27, 2013 at 11:24:34AM +1100, Victor Hooi wrote:

Quite apart from your question but if you do this:

> def get_pg_connection(logger_name, database_config):
...
>     except psycopg2.OperationalError as e:
>         logger.error('Error connecting to database {0[host]}:{0[port]}/{0[dbname]} - {1}'.format(database_config, e),
exc_info=True)
...
>     except Exception as e:
>         logger.error('Error - {}'.format(e), exc_info=True)

you will see UnicodeDecodeError from the logger
infrastructure as soon as the PostgreSQL error message
contains characters which don't fit the ASCII subset.
This will happen as soon as PostgreSQL is set to
a locale other then C or en_*

Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


В списке psycopg по дате отправления:

Предыдущее
От: Victor Hooi
Дата:
Сообщение: Using context managers for connections/cursors - cursors are closed, connections are not?
Следующее
От: Daniele Varrazzo
Дата:
Сообщение: Re: Using context managers for connections/cursors - cursors are closed, connections are not?