Skip to content

Commit 12b56e4

Browse files
gh-81040: Improve sqlite3.Cursor.rowcount docs (GH-94940)
(cherry picked from commit f9b3706) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent a61aa52 commit 12b56e4

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Doc/library/sqlite3.rst

+5-12
Original file line numberDiff line numberDiff line change
@@ -956,18 +956,11 @@ Cursor Objects
956956

957957
.. attribute:: rowcount
958958

959-
Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this
960-
attribute, the database engine's own support for the determination of "rows
961-
affected"/"rows selected" is quirky.
962-
963-
For :meth:`executemany` statements, the number of modifications are summed up
964-
into :attr:`rowcount`.
965-
966-
As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
967-
case no ``executeXX()`` has been performed on the cursor or the rowcount of the
968-
last operation is not determinable by the interface". This includes ``SELECT``
969-
statements because we cannot determine the number of rows a query produced
970-
until all rows were fetched.
959+
Read-only attribute that provides the number of modified rows for
960+
``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements;
961+
is ``-1`` for other statements,
962+
including :abbr:`CTE (Common Table Expression)` queries.
963+
It is only updated by the :meth:`execute` and :meth:`executemany` methods.
971964

972965
.. attribute:: lastrowid
973966

0 commit comments

Comments
 (0)