Skip to content

Commit 7bcc42a

Browse files
erlend-aaslandmiss-islington
authored andcommitted
pythongh-81040: Improve sqlite3.Cursor.rowcount docs (pythonGH-94940)
(cherry picked from commit f9b3706) Co-authored-by: Erlend Egeberg Aasland <[email protected]>
1 parent 7956186 commit 7bcc42a

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
@@ -793,18 +793,11 @@ Cursor Objects
793793

794794
.. attribute:: rowcount
795795

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

809802
.. attribute:: lastrowid
810803

0 commit comments

Comments
 (0)