Re: [psycopg] Changing set_session implementation

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: [psycopg] Changing set_session implementation
Дата
Msg-id 20170731105109.mjiimmdm3ixr7hyr@hermes.hilbert.loc
обсуждение исходный текст
Ответ на Re: [psycopg] Changing set_session implementation  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: [psycopg] Changing set_session implementation  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Список psycopg
Hopefully I just hit summer vacation -- or else do I need to
provide more information to get an answer on the below ?

Thanks,
Karsten

On Thu, Jul 27, 2017 at 04:17:33PM +0200, Karsten Hilbert wrote:

> On Sat, Feb 04, 2017 at 04:33:13PM +0000, Daniele Varrazzo wrote:
>
> > I've changed the set_session/set_isolation_level/autocommit connection
> > methods and properties to use better the BEGIN parameters
> ...
> > Conversely:
> >
> >     conn.set_session(readonly=True, autocommit=True)
>
> Does this mean that
>
>     conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
>
> is now a no-op as observed by the following log snippet or
> just diverted to set_session(autocommit=True) ?
>
>
> code:
>
>     _log.debug('conn state now: %s', gmPG2.capture_conn_state(self.conn))
>     _log.debug('setting isolation level to autocommit - should be redundant ?')
>     self.conn.set_isolation_level(0)
>     _log.debug('conn state now: %s', gmPG2.capture_conn_state(self.conn))
>
> log:
>
>     2017-07-27 16:03:01  DEBUG     gm.bootstrapper  MainThread (-1219281664)
(./bootstrap_gm_db_system.py::__create_db()#810): conn state now: <connection object at 0xb64eca04; dsn:
'dbname=gnumed_v21port=5432 user=postgres sslmode=prefer fallback_application_name=GNUmed client_encoding=utf8
application_name=postgres@template.db',closed: 0> 
>                        type: <class 'psycopg2.extras.DictConnection'>
>                    identity: 3058616836
>                 backend PID: 2864
>            protocol version: 3
>                    encoding: UTF8
>     isolation level (psyco): 3 (ISOLATION_LEVEL_SERIALIZABLE)
>                    readonly: False
>                  autocommit: True
>                      closed: 0
>           connection status: 1 (STATUS_READY)
>          transaction status: 0 (TRANSACTION_STATUS_IDLE)
>                  deferrable: None
>                       async: 0
>          executing async op: False
>     2017-07-27 16:03:01  DEBUG     gm.bootstrapper  MainThread (-1219281664)
(./bootstrap_gm_db_system.py::__create_db()#811): setting isolation level to autocommit - should be redundant ? 
>     2017-07-27 16:03:01  DEBUG     gm.bootstrapper  MainThread (-1219281664)
(./bootstrap_gm_db_system.py::__create_db()#813): conn state now: <connection object at 0xb64eca04; dsn:
'dbname=gnumed_v21port=5432 user=postgres sslmode=prefer fallback_application_name=GNUmed client_encoding=utf8
application_name=postgres@template.db',closed: 0> 
>                        type: <class 'psycopg2.extras.DictConnection'>
>                    identity: 3058616836
>                 backend PID: 2864
>            protocol version: 3
>                    encoding: UTF8
>     isolation level (psyco): 3 (ISOLATION_LEVEL_SERIALIZABLE)
>                    readonly: False
>                  autocommit: True
>                      closed: 0
>           connection status: 1 (STATUS_READY)
>          transaction status: 0 (TRANSACTION_STATUS_IDLE)
>                  deferrable: None
>                       async: 0
>          executing async op: False
>
>
> Note that it doesn't actually change the isolation level
> (which makes sense because autocommit mode is not an
> isolation level). Should conn.isolation_level show
> ISOLATION_LEVEL_DEFAULT in this case (meaning "use what the
> server/db is configured for") ?  It doesn't seem to make a
> roundtrip to the server to _get_ the default because the
> database in question defaults to READ_COMMITED. The
> SERIALIZABLE results from an earlier call to
> .set_isolation_mode() in my code.
>
> (Also note that the connection had already been set to
>  autocommit by "set_session(autocommit=True)" before.)
>
>
> Thanks for the clarification,
> Karsten
> --
> GPG key ID E4071346 @ eu.pool.sks-keyservers.net
> E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346
>
>
> --
> Sent via psycopg mailing list (psycopg@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/psycopg

--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


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

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Re: [psycopg] Changing set_session implementation
Следующее
От: Stephen Quintero
Дата:
Сообщение: [psycopg] psycopg2: distinguishing connect failures through exception handling