From 86b8244b41e38ac47ecab0f3940195834b78dd8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Mon, 21 Nov 2022 20:56:42 +0100 Subject: [PATCH 1/7] Document sqlite3.connect() as implicitly opening transactions in the new PEP-249 manual commit mode --- Doc/library/sqlite3.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 0dac2312b2feb1..66d43db962640b 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2467,10 +2467,9 @@ It is suggested to set *autocommit* to ``False``, which implies :pep:`249`-compliant transaction control. This means: -* :mod:`!sqlite3` ensures that a transaction is always open, - so :meth:`Connection.commit` and :meth:`Connection.rollback` - will implicitly open a new transaction immediately after closing - the pending one. +* :func:`connect`, :meth:`Connection.commit`, and :meth:`Connection.rollback` + implicitly open a new transaction to ensure that a transaction is always + open. :mod:`!sqlite3` uses ``BEGIN DEFERRED`` statements when opening transactions. * Transactions should be committed explicitly using :meth:`!commit`. * Transactions should be rolled back explicitly using :meth:`!rollback`. From c3963f4fd2d4a4e71c041944ed702d0bc44b51a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Mon, 28 Nov 2022 18:01:07 +0100 Subject: [PATCH 2/7] Document sqlite3.connect() as implicitly opening transactions in the new PEP-249 manual commit mode --- Doc/library/sqlite3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 66d43db962640b..c23b00b09dc98a 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -263,6 +263,7 @@ Module functions autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL) Open a connection to an SQLite database. + If *autocommit* is ``False``, a new transaction is implicitly opened. :param database: The path to the database file to be opened. From 9cbd2c675ff420dbf6bdc59e16c87ac9667b9613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Mon, 28 Nov 2022 18:01:22 +0100 Subject: [PATCH 3/7] Revert "Document sqlite3.connect() as implicitly opening transactions in the new PEP-249 manual commit mode" This reverts commit 86b8244b41e38ac47ecab0f3940195834b78dd8c. --- Doc/library/sqlite3.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index c23b00b09dc98a..0b4887483357d6 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -2468,9 +2468,10 @@ It is suggested to set *autocommit* to ``False``, which implies :pep:`249`-compliant transaction control. This means: -* :func:`connect`, :meth:`Connection.commit`, and :meth:`Connection.rollback` - implicitly open a new transaction to ensure that a transaction is always - open. +* :mod:`!sqlite3` ensures that a transaction is always open, + so :meth:`Connection.commit` and :meth:`Connection.rollback` + will implicitly open a new transaction immediately after closing + the pending one. :mod:`!sqlite3` uses ``BEGIN DEFERRED`` statements when opening transactions. * Transactions should be committed explicitly using :meth:`!commit`. * Transactions should be rolled back explicitly using :meth:`!rollback`. From a9273c61b8f41cc0d3ca3147e8e8585b1bb5883f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Mon, 28 Nov 2022 23:59:26 +0100 Subject: [PATCH 4/7] =?UTF-8?q?Apply=20Erlend=E2=80=99s=20change=20suggest?= =?UTF-8?q?ion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Doc/library/sqlite3.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 0b4887483357d6..d51d96131dac0d 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -263,7 +263,6 @@ Module functions autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL) Open a connection to an SQLite database. - If *autocommit* is ``False``, a new transaction is implicitly opened. :param database: The path to the database file to be opened. @@ -326,6 +325,7 @@ Module functions enabling various :ref:`sqlite3-uri-tricks`. :param autocommit: + If *autocommit* is ``False``, a new transaction is implicitly opened. See :attr:`Connection.autocommit` and :ref:`sqlite3-transaction-control-autocommit` for more information. *autocommit* currently defaults to From 452c52a03d8d92e2e43c46ea8ac407ac65f4cd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Tue, 29 Nov 2022 10:04:47 +0100 Subject: [PATCH 5/7] Move and extend the implicit transaction opening sentence for connect() Co-authored-by: C.A.M. Gerlach --- Doc/library/sqlite3.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index d51d96131dac0d..dfd2727a7fae03 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -325,9 +325,11 @@ Module functions enabling various :ref:`sqlite3-uri-tricks`. :param autocommit: - If *autocommit* is ``False``, a new transaction is implicitly opened. + Controls :pep:`249` transaction handling behaviour. See :attr:`Connection.autocommit` and :ref:`sqlite3-transaction-control-autocommit` for more information. + If ``False``, a new transaction is implicitly opened + when the :class:`Connection` is created. *autocommit* currently defaults to :data:`~sqlite3.LEGACY_TRANSACTION_CONTROL`. The default will change to ``False`` in a future Python release. From d866e90abe0da7c3997da25af8e21fbdac11aa79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Tue, 29 Nov 2022 10:07:19 +0100 Subject: [PATCH 6/7] Add a similar descriptive sentence for the isolation_level parameter --- Doc/library/sqlite3.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index dfd2727a7fae03..cd56316f6dc13a 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -292,6 +292,7 @@ Module functions By default (``0``), type detection is disabled. :param isolation_level: + Control legacy transaction handling behaviour. See :attr:`Connection.isolation_level` and :ref:`sqlite3-transaction-control-isolation-level` for more information. Can be ``"DEFERRED"`` (default), ``"EXCLUSIVE"`` or ``"IMMEDIATE"``; @@ -325,7 +326,7 @@ Module functions enabling various :ref:`sqlite3-uri-tricks`. :param autocommit: - Controls :pep:`249` transaction handling behaviour. + Control :pep:`249` transaction handling behaviour. See :attr:`Connection.autocommit` and :ref:`sqlite3-transaction-control-autocommit` for more information. If ``False``, a new transaction is implicitly opened From 0d15229dfaebcc31b8aad17ef3a75ec19dde1e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Ogam?= Date: Wed, 30 Nov 2022 12:03:10 +0100 Subject: [PATCH 7/7] =?UTF-8?q?Apply=20CAM=E2=80=99s=20suggested=20change?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Doc/library/sqlite3.rst | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index cd56316f6dc13a..2a9ad39b717a90 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -292,7 +292,6 @@ Module functions By default (``0``), type detection is disabled. :param isolation_level: - Control legacy transaction handling behaviour. See :attr:`Connection.isolation_level` and :ref:`sqlite3-transaction-control-isolation-level` for more information. Can be ``"DEFERRED"`` (default), ``"EXCLUSIVE"`` or ``"IMMEDIATE"``; @@ -326,11 +325,8 @@ Module functions enabling various :ref:`sqlite3-uri-tricks`. :param autocommit: - Control :pep:`249` transaction handling behaviour. See :attr:`Connection.autocommit` and :ref:`sqlite3-transaction-control-autocommit` for more information. - If ``False``, a new transaction is implicitly opened - when the :class:`Connection` is created. *autocommit* currently defaults to :data:`~sqlite3.LEGACY_TRANSACTION_CONTROL`. The default will change to ``False`` in a future Python release. @@ -2472,9 +2468,9 @@ which implies :pep:`249`-compliant transaction control. This means: * :mod:`!sqlite3` ensures that a transaction is always open, - so :meth:`Connection.commit` and :meth:`Connection.rollback` - will implicitly open a new transaction immediately after closing - the pending one. + so :func:`connect`, :meth:`Connection.commit`, and :meth:`Connection.rollback` + will implicitly open a new transaction + (immediately after closing the pending one, for the latter two). :mod:`!sqlite3` uses ``BEGIN DEFERRED`` statements when opening transactions. * Transactions should be committed explicitly using :meth:`!commit`. * Transactions should be rolled back explicitly using :meth:`!rollback`.