Exposing ISOLATION_LEVEL_DEFAULT to Python

This is now the state that is returned to Python if nothing has been
explicitly set.
This commit is contained in:
Daniele Varrazzo 2017-02-04 14:43:54 +00:00
parent c60682c230
commit 665e9dc665
3 changed files with 11 additions and 1 deletions

View File

@ -651,6 +651,15 @@ set to one of the following constants:
.. __: http://www.postgresql.org/docs/current/static/transaction-iso.html#XACT-SERIALIZABLE
.. data:: ISOLATION_LEVEL_DEFAULT
Whatever is defined by the server, either via server configuration or by
statements executed within the session outside Pyscopg control; Psycopg
will not force an isolation level of its own. If you want to know what the
value is you can use a query such as :sql:`show transaction_isolation` or
:sql:`show default_transaction_isolation`.
.. versionadded:: 2.7
.. index::

View File

@ -72,6 +72,7 @@ ISOLATION_LEVEL_READ_UNCOMMITTED = 4
ISOLATION_LEVEL_READ_COMMITTED = 1
ISOLATION_LEVEL_REPEATABLE_READ = 2
ISOLATION_LEVEL_SERIALIZABLE = 3
ISOLATION_LEVEL_DEFAULT = 5
"""psycopg connection status values."""

View File

@ -488,7 +488,7 @@ class IsolationLevelsTestCase(ConnectingTestCase):
conn = self.connect()
self.assertEqual(
conn.isolation_level,
psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED)
psycopg2.extensions.ISOLATION_LEVEL_DEFAULT)
def test_encoding(self):
conn = self.connect()