Skip to content

Commit a530b3e

Browse files
Address reviews
1 parent 576c760 commit a530b3e

File tree

1 file changed

+27
-37
lines changed

1 file changed

+27
-37
lines changed

Doc/library/sqlite3.rst

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -406,19 +406,18 @@ Connection Objects
406406

407407
.. attribute:: isolation_level
408408

409-
Get or set the current default isolation level.
409+
Get or set the isolation level.
410410
Set to :const:`None` to disable implicit transaction handling,
411-
or one of "", "DEFERRED", "IMMEDIATE" or "EXCLUSIVE".
412-
Defaults to the former (`""`), unless overridden at :func:`connect`,
413-
using the *isolation_level* parameter.
414-
Both "" and "DEFERRED" carry the same meaning;
415-
they imply deferred isolation level.
411+
or to one of the ``"DEFERRED"``, ``"IMMEDIATE"``, or ``"EXCLUSIVE"``
412+
transaction handling modes.
413+
If not overridden by the *isolation_level* parameter of :func:`connect`,
414+
the default is ``""``, which is an alias for ``"DEFERRED"``.
416415
See :ref:`sqlite3-controlling-transactions` for more details.
417416

418417
.. attribute:: in_transaction
419418

420-
This read-only attribute corresponds to the low-level SQLite autocommit
421-
mode.
419+
This read-only attribute corresponds to the low-level SQLite
420+
`autocommit mode`_.
422421

423422
:const:`True` if a transaction is active (there are uncommitted changes),
424423
:const:`False` otherwise.
@@ -884,8 +883,8 @@ Cursor Objects
884883
:meth:`executescript` if you want to execute multiple SQL statements with one
885884
call.
886885

887-
If :attr:`isolation_level` is not :const:`None`,
888-
*sql* is an INSERT, UPDATE, DELETE, or REPLACE statement,
886+
If :attr:`~Connection.isolation_level` is not :const:`None`,
887+
*sql* is an ``INSERT``, ``UPDATE``, ``DELETE``, or ``REPLACE`` statement,
889888
and there is no open transaction,
890889
a transaction is implicitly opened before executing *sql*.
891890

@@ -1441,45 +1440,36 @@ Controlling Transactions
14411440
------------------------
14421441

14431442
The ``sqlite3`` module does not adhere to the transaction handling recommended
1444-
by PEP 249.
1445-
If the connection attribute :attr:`isolation_level` is not :const:`None`,
1446-
the following implicit transaction handling is performed:
1447-
New transactions are implicitly opened before
1448-
:meth:`~Cursor.execute` and :meth:`~Cursor.executemany` executes any of the
1449-
following statements:
1450-
1451-
* INSERT
1452-
* UPDATE
1453-
* DELETE
1454-
* REPLACE
1455-
1456-
In addition, any pending transaction is implicitly committed in
1457-
:meth:`~Cursor.executescript`, before execution of the given SQL script.
1443+
by :pep:`249`.
1444+
If the connection attribute :attr:`~Connection.isolation_level`
1445+
is not :const:`None`,
1446+
new transactions are implicitly opened before
1447+
:meth:`~Cursor.execute` and :meth:`~Cursor.executemany` executes
1448+
``INSERT``, ``UPDATE``, ``DELETE``, or ``REPLACE`` statements.
1449+
1450+
The :meth:`~Cursor.executescript` method implicitly commits
1451+
any pending transaction before execution of the given SQL script.
14581452
No other implicit transaction handling is performed.
1459-
Use the :meth:`~Connection.commit` and :meth:`~Connection.rollback` method
1453+
Use the :meth:`~Connection.commit` and :meth:`~Connection.rollback` methods
14601454
to respectively commit and roll back pending transactions.
14611455

14621456
You can control which kind of ``BEGIN`` statements ``sqlite3`` implicitly
1463-
executes via the :attr:`isolation_level` connection attribute.
1457+
executes via the :attr:`~Connection.isolation_level` attribute.
14641458

14651459
The ``sqlite3`` module lets the user bypass its transaction handling by
1466-
setting :attr:`isolation_level` to :const:`None`.
1467-
This leaves the underlying SQLite library in autocommit mode,
1468-
but also allows the user to perform any transaction handling using explicit SQL
1469-
statements.
1460+
setting :attr:`~Connection.isolation_level` to :const:`None`.
1461+
This leaves the underlying SQLite library in `autocommit mode`_,
1462+
but also allows the user to perform their own transaction handling
1463+
using explicit SQL statements.
14701464
The underlying SQLite library autocommit mode can be queried using the
1471-
:attr:`in_transaction` connection attribute.
1472-
1473-
.. note::
1474-
1475-
PEP 249's autocommit concept must not be mistaken for SQLite's autocommit
1476-
mode.
1477-
Though related, they are different concepts with different semantics.
1465+
:attr:`~Connection.in_transaction` attribute.
14781466

14791467
.. versionchanged:: 3.6
14801468
:mod:`sqlite3` used to implicitly commit an open transaction before DDL
14811469
statements. This is no longer the case.
14821470

1471+
.. _autocommit mode: https://sqlite.org/lang_transaction.html
1472+
14831473

14841474
Using :mod:`sqlite3` efficiently
14851475
--------------------------------

0 commit comments

Comments
 (0)