Skip to content
Snippets Groups Projects
Unverified Commit f9b3706d authored by Erlend Egeberg Aasland's avatar Erlend Egeberg Aasland Committed by GitHub
Browse files

gh-81040: Improve sqlite3.Cursor.rowcount docs (#94940)

parent 934b25dc
No related branches found
No related tags found
No related merge requests found
...@@ -966,18 +966,11 @@ Cursor Objects ...@@ -966,18 +966,11 @@ Cursor Objects
.. attribute:: rowcount .. attribute:: rowcount
Although the :class:`Cursor` class of the :mod:`sqlite3` module implements this Read-only attribute that provides the number of modified rows for
attribute, the database engine's own support for the determination of "rows ``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements;
affected"/"rows selected" is quirky. is ``-1`` for other statements,
including :abbr:`CTE (Common Table Expression)` queries.
For :meth:`executemany` statements, the number of modifications are summed up It is only updated by the :meth:`execute` and :meth:`executemany` methods.
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.
.. attribute:: lastrowid .. attribute:: lastrowid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment