From 1950829dc013089db0d47ce3e010fb92b41e28f9 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Mon, 18 Jul 2022 00:17:29 +0200 Subject: [PATCH 1/2] gh-81040: Improve sqlite3.Cursor.rowcount docs --- Doc/library/sqlite3.rst | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index d2997dc9251786..0756f2366f425a 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -966,18 +966,11 @@ Cursor Objects .. attribute:: rowcount - Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this - attribute, the database engine's own support for the determination of "rows - affected"/"rows selected" is quirky. - - For :meth:`executemany` statements, the number of modifications are summed up - into :attr:`rowcount`. - - As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in - case no ``executeXX()`` has been performed on the cursor or the rowcount of the - last operation is not determinable by the interface". This includes ``SELECT`` - statements because we cannot determine the number of rows a query produced - until all rows were fetched. + This read-only attribute provides the number of modified rows for + ``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements; + ``-1`` for other statements, + including :abbr:`CTE queries (Common Table Expression)`. + It is only updated by the :meth:`execute` and :meth:`executemany` methods. .. attribute:: lastrowid From cdd0bcd561c6c02e65596aec53391ace6e766d88 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Fri, 22 Jul 2022 09:12:50 +0200 Subject: [PATCH 2/2] Address CAM's review --- Doc/library/sqlite3.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/sqlite3.rst b/Doc/library/sqlite3.rst index 0756f2366f425a..a8d1eb2be9e296 100644 --- a/Doc/library/sqlite3.rst +++ b/Doc/library/sqlite3.rst @@ -966,10 +966,10 @@ Cursor Objects .. attribute:: rowcount - This read-only attribute provides the number of modified rows for + Read-only attribute that provides the number of modified rows for ``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements; - ``-1`` for other statements, - including :abbr:`CTE queries (Common Table Expression)`. + is ``-1`` for other statements, + including :abbr:`CTE (Common Table Expression)` queries. It is only updated by the :meth:`execute` and :meth:`executemany` methods. .. attribute:: lastrowid