@@ -654,7 +654,7 @@ Connection objects
654
654
If :attr: `autocommit ` is ``False ``, this method implicitly rolls back
655
655
any open transaction before closing.
656
656
If :attr: `!autocommit ` is ``True `` or :data: `LEGACY_TRANSACTION_CONTROL `,
657
- this method does not execute any implicit transaction control.
657
+ this method does not perform any implicit transaction control.
658
658
Make sure to :meth: `commit ` before closing
659
659
to avoid losing pending changes.
660
660
@@ -1257,17 +1257,16 @@ Connection objects
1257
1257
This attribute controls :pep: `249 `-compliant transaction behaviour.
1258
1258
:attr: `!autocommit ` has three allowed values:
1259
1259
1260
- * ``False ``: Select :pep: `249 `-compliant transaction behaviour,
1261
- implying that :mod: `!sqlite3 ` ensures a transaction is always open.
1260
+ * ``False ``: :pep: `249 `-compliant manual commit mode.
1262
1261
Use :meth: `commit ` and :meth: `rollback ` to close transactions.
1263
1262
1264
1263
This is the recommended value of :attr: `!autocommit `.
1265
1264
1266
- * ``True ``: Use SQLite's ` autocommit mode `_ .
1265
+ * ``True ``: :pep: ` 249 `-compliant autocommit mode.
1267
1266
:meth: `commit ` and :meth: `rollback ` have no effect in this mode.
1268
1267
1269
1268
* :data: `LEGACY_TRANSACTION_CONTROL `:
1270
- Pre-Python 3.12 (non- :pep: `249 `-compliant) transaction control.
1269
+ Non- :pep: `249 `-compliant (pre-Python 3.12 ) transaction control.
1271
1270
See :attr: `isolation_level ` for more details.
1272
1271
1273
1272
This is currently the default value of :attr: `!autocommit `.
@@ -1286,7 +1285,7 @@ Connection objects
1286
1285
1287
1286
.. attribute :: in_transaction
1288
1287
1289
- This read-only attribute corresponds to the low-level SQLite
1288
+ This read-only attribute corresponds to the low-level SQLite's
1290
1289
`autocommit mode `_.
1291
1290
1292
1291
``True `` if a transaction is active (there are uncommitted changes),
@@ -2385,30 +2384,35 @@ the :attr:`Connection.autocommit` attribute,
2385
2384
which should preferrably be set using the *autocommit * parameter
2386
2385
of :func: `connect `.
2387
2386
2388
- It is suggested to set *autocommit * to ``False ``,
2389
- which implies :pep: `249 `-compliant transaction control .
2387
+ It is suggested to set *autocommit * to ``False `` to enable the
2388
+ :pep: `249 `-compliant manual commit mode .
2390
2389
This means:
2391
2390
2392
- * :mod: `!sqlite3 ` ensures that a transaction is always open,
2393
- so :meth: `Connection.commit ` and :meth: `Connection.rollback `
2394
- will implicitly open a new transaction immediately after closing
2395
- the open one.
2396
- :mod: `!sqlite3 ` uses ``BEGIN DEFERRED `` statements when opening transactions.
2397
- * Transactions should be committed explicitly using :meth: `!commit `.
2398
- * Transactions should be rolled back explicitly using :meth: `!rollback `.
2399
- * An implicit rollback is performed if the database is
2400
- :meth: `~Connection.close `-ed with pending changes.
2401
-
2402
- Set *autocommit * to ``True `` to enable SQLite's `autocommit mode `_.
2403
- In this mode, :meth: `Connection.commit ` and :meth: `Connection.rollback `
2404
- have no effect.
2391
+ * :meth: `Connection.connect `, :meth: `Connection.commit `,
2392
+ and :meth: `Connection.rollback ` implicitly open a new transaction to ensure
2393
+ that a transaction is always open.
2394
+ Those methods use a ``BEGIN DEFERRED `` statement when opening a transaction.
2395
+ * Transactions should be explicitly committed using :meth: `!commit `.
2396
+ * Transactions should be explicitly rolled back using :meth: `!rollback `.
2397
+ * :meth: `Connection.close ` implicitly rolls back any open transaction.
2398
+
2399
+ Set *autocommit * to ``True `` to enable the :pep: `249 `-compliant autocommit mode.
2400
+ This means:
2401
+
2402
+ * No implicit transaction control is performed.
2403
+ This leaves SQLite in `autocommit mode `_,
2404
+ but also allows the user to perform their own transaction control
2405
+ using explicit SQL-transaction statements.
2406
+ * :meth: `Connection.commit ` and :meth: `Connection.rollback ` have no effect.
2407
+
2405
2408
Note that SQLite's autocommit mode is distinct from
2406
2409
the :pep: `249 `-compliant :attr: `Connection.autocommit ` attribute;
2407
- use :attr: ` Connection.in_transaction ` to query
2408
- the low-level SQLite autocommit mode .
2410
+ SQLite's autocommit mode can be queried using the
2411
+ :attr: ` Connection.in_transaction ` attribute .
2409
2412
2410
- Set *autocommit * to :data: `LEGACY_TRANSACTION_CONTROL `
2411
- to leave transaction control behaviour to the
2413
+ Set *autocommit * to :data: `LEGACY_TRANSACTION_CONTROL ` to enable
2414
+ non-:pep: `249 `-compliant (pre-Python 3.12) transaction control.
2415
+ This means transaction control behaviour is left to the
2412
2416
:attr: `Connection.isolation_level ` attribute.
2413
2417
See :ref: `sqlite3-transaction-control-isolation-level ` for more information.
2414
2418
@@ -2430,29 +2434,29 @@ transaction behaviour is controlled using
2430
2434
the :attr: `Connection.isolation_level ` attribute.
2431
2435
Otherwise, :attr: `!isolation_level ` has no effect.
2432
2436
2433
- If the connection attribute :attr: `~Connection.isolation_level `
2434
- is not ``None ``,
2435
- new transactions are implicitly opened before
2436
- :meth: `~Cursor.execute ` and :meth: `~Cursor.executemany ` executes
2437
- ``INSERT ``, ``UPDATE ``, ``DELETE ``, or ``REPLACE `` statements;
2438
- for other statements, no implicit transaction handling is performed.
2439
- Use the :meth: `~Connection.commit ` and :meth: `~Connection.rollback ` methods
2440
- to respectively commit and roll back open transactions.
2441
- You can choose the underlying `SQLite transaction behaviour `_ —
2442
- that is, whether and what type of ``BEGIN `` statements :mod: `!sqlite3 `
2443
- implicitly executes –
2444
- via the :attr: `~Connection.isolation_level ` attribute.
2437
+ If :attr: `~Connection.isolation_level ` is not ``None ``:
2438
+
2439
+ * :meth: `~Cursor.execute ` and :meth: `~Cursor.executemany `
2440
+ implicitly open new a transaction before executing an
2441
+ ``INSERT ``, ``UPDATE ``, ``DELETE ``, or ``REPLACE `` statement;
2442
+ for other statements, no implicit transaction control is performed.
2443
+ The type of ``BEGIN `` statement that those methods use for the underlying
2444
+ `SQLite transaction behaviour `_ can be chosen via the
2445
+ :attr: `~Connection.isolation_level ` attribute.
2446
+ * Transactions should be explicitly committed using :meth: `!commit `.
2447
+ * Transactions should be explicitly rolled back using :meth: `!rollback `.
2445
2448
2446
2449
If :attr: `~Connection.isolation_level ` is set to ``None ``,
2447
- no transactions are implicitly opened at all.
2448
- This leaves the underlying SQLite library in `autocommit mode `_,
2449
- but also allows the user to perform their own transaction handling
2450
- using explicit SQL statements.
2451
- The underlying SQLite library autocommit mode can be queried using the
2450
+ no implicit transaction control is performed.
2451
+ This leaves SQLite in `autocommit mode `_,
2452
+ but also allows the user to perform their own transaction control
2453
+ using explicit SQL-transaction statements.
2454
+
2455
+ SQLite's autocommit mode can be queried using the
2452
2456
:attr: `~Connection.in_transaction ` attribute.
2453
2457
2454
- The :meth: `~Cursor.executescript ` method implicitly commits
2455
- any open transaction before execution of the given SQL script,
2458
+ :meth: `~Cursor.executescript ` implicitly commits
2459
+ any open transaction before executing the given SQL script,
2456
2460
regardless of the value of :attr: `~Connection.isolation_level `.
2457
2461
2458
2462
.. versionchanged :: 3.6
0 commit comments