summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2018-07-29 09:01:38 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2018-07-29 09:01:38 (GMT)
commita71fed0b7596f1c11a2fa6c1b7311157148f5f9f (patch)
treeb66fbcfa8fd7bd1a6935966528f87174622986aa /Doc
parent11eb1a94704142385ffc07852739863ced8587d2 (diff)
downloadcpython-a71fed0b7596f1c11a2fa6c1b7311157148f5f9f.zip
cpython-a71fed0b7596f1c11a2fa6c1b7311157148f5f9f.tar.gz
cpython-a71fed0b7596f1c11a2fa6c1b7311157148f5f9f.tar.bz2
bpo-8145: Improve isolation_level documentation (GH-8499)
Initial patch by R. David Murray.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/sqlite3.rst36
1 files changed, 22 insertions, 14 deletions
diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst
index 37d2a4f..9e3c56b 100644
--- a/Doc/library/sqlite3.rst
+++ b/Doc/library/sqlite3.rst
@@ -281,7 +281,7 @@ Connection Objects
.. attribute:: isolation_level
- Get or set the current isolation level. :const:`None` for autocommit mode or
+ Get or set the current default isolation level. :const:`None` for autocommit mode or
one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section
:ref:`sqlite3-controlling-transactions` for a more detailed explanation.
@@ -1010,22 +1010,30 @@ timestamp converter.
Controlling Transactions
------------------------
-By default, the :mod:`sqlite3` module opens transactions implicitly before a
-Data Modification Language (DML) statement (i.e.
-``INSERT``/``UPDATE``/``DELETE``/``REPLACE``).
-
-You can control which kind of ``BEGIN`` statements sqlite3 implicitly executes
-(or none at all) via the *isolation_level* parameter to the :func:`connect`
-call, or via the :attr:`isolation_level` property of connections.
+The underlying ``sqlite3`` library operates in ``autocommit`` mode by default,
+but the Python :mod:`sqlite3` module by default does not.
-If you want **autocommit mode**, then set :attr:`isolation_level` to ``None``.
+``autocommit`` mode means that statements that modify the database take effect
+immediately. A ``BEGIN`` or ``SAVEPOINT`` statement disables ``autocommit``
+mode, and a ``COMMIT``, a ``ROLLBACK``, or a ``RELEASE`` that ends the
+outermost transaction, turns ``autocommit`` mode back on.
-Otherwise leave it at its default, which will result in a plain "BEGIN"
-statement, or set it to one of SQLite's supported isolation levels: "DEFERRED",
-"IMMEDIATE" or "EXCLUSIVE".
+The Python :mod:`sqlite3` module by default issues a ``BEGIN`` statement
+implicitly before a Data Modification Language (DML) statement (i.e.
+``INSERT``/``UPDATE``/``DELETE``/``REPLACE``).
-The current transaction state is exposed through the
-:attr:`Connection.in_transaction` attribute of the connection object.
+You can control which kind of ``BEGIN`` statements :mod:`sqlite3` implicitly
+executes via the *isolation_level* parameter to the :func:`connect`
+call, or via the :attr:`isolation_level` property of connections.
+If you specify no *isolation_level*, a plain ``BEGIN`` is used, which is
+equivalent to specifying ``DEFERRED``. Other possible values are ``IMMEDIATE``
+and ``EXCLUSIVE``.
+
+You can disable the :mod:`sqlite3` module's implicit transaction management by
+setting :attr:`isolation_level` to ``None``. This will leave the underlying
+``sqlite3`` library operating in ``autocommit`` mode. You can then completely
+control the transaction state by explicitly issuing ``BEGIN``, ``ROLLBACK``,
+``SAVEPOINT``, and ``RELEASE`` statements in your code.
.. versionchanged:: 3.6
:mod:`sqlite3` used to implicitly commit an open transaction before DDL