@@ -406,19 +406,18 @@ Connection Objects
406
406
407
407
.. attribute :: isolation_level
408
408
409
- Get or set the current default isolation level.
409
+ Get or set the isolation level.
410
410
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" ``.
416
415
See :ref: `sqlite3-controlling-transactions ` for more details.
417
416
418
417
.. attribute :: in_transaction
419
418
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`_ .
422
421
423
422
:const: `True ` if a transaction is active (there are uncommitted changes),
424
423
:const: `False ` otherwise.
@@ -884,8 +883,8 @@ Cursor Objects
884
883
:meth: `executescript ` if you want to execute multiple SQL statements with one
885
884
call.
886
885
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,
889
888
and there is no open transaction,
890
889
a transaction is implicitly opened before executing *sql *.
891
890
@@ -1441,45 +1440,36 @@ Controlling Transactions
1441
1440
------------------------
1442
1441
1443
1442
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.
1458
1452
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
1460
1454
to respectively commit and roll back pending transactions.
1461
1455
1462
1456
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.
1464
1458
1465
1459
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.
1470
1464
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.
1478
1466
1479
1467
.. versionchanged :: 3.6
1480
1468
:mod: `sqlite3 ` used to implicitly commit an open transaction before DDL
1481
1469
statements. This is no longer the case.
1482
1470
1471
+ .. _autocommit mode : https://sqlite.org/lang_transaction.html
1472
+
1483
1473
1484
1474
Using :mod: `sqlite3 ` efficiently
1485
1475
--------------------------------
0 commit comments