@@ -406,13 +406,15 @@ Connection Objects
406
406
407
407
.. attribute :: isolation_level
408
408
409
- Get or set the isolation level.
410
- Set to :const: `None ` to disable implicit transaction handling,
411
- or to one of the ``"DEFERRED" ``, ``"IMMEDIATE" ``, or ``"EXCLUSIVE" ``
412
- transaction handling modes.
409
+ This attribute controls the :ref: `transaction handling
410
+ <sqlite3-controlling-transactions>` performed by ``sqlite3 ``.
411
+ If set to :const: `None `, transactions are never implicitly opened.
412
+ If set to one of ``"DEFERRED" ``, ``"IMMEDIATE" ``, or ``"EXCLUSIVE" ``,
413
+ the strings representing the underlying SQLite `transaction behaviour `_,
414
+ transactions are implicitly opened before some DML statements.
415
+
413
416
If not overridden by the *isolation_level * parameter of :func: `connect `,
414
417
the default is ``"" ``, which is an alias for ``"DEFERRED" ``.
415
- See :ref: `sqlite3-controlling-transactions ` for more details.
416
418
417
419
.. attribute :: in_transaction
418
420
@@ -1441,34 +1443,37 @@ Controlling Transactions
1441
1443
1442
1444
The ``sqlite3 `` module does not adhere to the transaction handling recommended
1443
1445
by :pep: `249 `.
1446
+
1444
1447
If the connection attribute :attr: `~Connection.isolation_level `
1445
1448
is not :const: `None `,
1446
1449
new transactions are implicitly opened before
1447
1450
:meth: `~Cursor.execute ` and :meth: `~Cursor.executemany ` executes
1448
1451
``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.
1452
- No other implicit transaction handling is performed.
1453
1452
Use the :meth: `~Connection.commit ` and :meth: `~Connection.rollback ` methods
1454
1453
to respectively commit and roll back pending transactions.
1454
+ You can chose the underlying SQLite `transaction behaviour `_,
1455
+ that is the kind of ``BEGIN `` statements ``sqlite3 `` implicitly executes,
1456
+ via the :attr: `~Connection.isolation_level ` attribute.
1455
1457
1456
- You can control which kind of ``BEGIN `` statements ``sqlite3 `` implicitly
1457
- executes via the :attr: `~Connection.isolation_level ` attribute.
1458
-
1459
- The ``sqlite3 `` module lets the user bypass its transaction handling by
1460
- setting :attr: `~Connection.isolation_level ` to :const: `None `.
1458
+ If :attr: `~Connection.isolation_level ` is set to :const: `None `,
1459
+ no transactions are implicitly opened at all.
1461
1460
This leaves the underlying SQLite library in `autocommit mode `_,
1462
1461
but also allows the user to perform their own transaction handling
1463
1462
using explicit SQL statements.
1464
1463
The underlying SQLite library autocommit mode can be queried using the
1465
1464
:attr: `~Connection.in_transaction ` attribute.
1466
1465
1466
+ The :meth: `~Cursor.executescript ` method implicitly commits
1467
+ any pending transaction before execution of the given SQL script,
1468
+ regardless of the value of :attr: `~Connection.isolation_level `,
1469
+
1467
1470
.. versionchanged :: 3.6
1468
1471
:mod: `sqlite3 ` used to implicitly commit an open transaction before DDL
1469
1472
statements. This is no longer the case.
1470
1473
1471
- .. _autocommit mode : https://sqlite.org/lang_transaction.html
1474
+ .. _autocommit mode : https://www.sqlite.org/lang_transaction.html#implicit_versus_explicit_transactions
1475
+
1476
+ .. _transaction behaviour : https://www.sqlite.org/lang_transaction.html#deferred_immediate_and_exclusive_transactions
1472
1477
1473
1478
1474
1479
Using :mod: `sqlite3 ` efficiently
0 commit comments