Skip to content

Commit f9b3706

Browse files
gh-81040: Improve sqlite3.Cursor.rowcount docs (#94940)
1 parent 934b25d commit f9b3706

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
@@ -966,18 +966,11 @@ Cursor Objects
966966

967967
.. attribute:: rowcount
968968

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

982975
.. attribute:: lastrowid
983976

0 commit comments

Comments
 (0)