Skip to content

Commit

Permalink
pythongh-81040: Improve sqlite3.Cursor.rowcount docs (pythonGH-94940)
Browse files Browse the repository at this point in the history
(cherry picked from commit f9b3706)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
  • Loading branch information
erlend-aasland authored and miss-islington committed Jul 22, 2022
1 parent a61aa52 commit bca4b3d
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -956,18 +956,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.
Read-only attribute that provides the number of modified rows for
``INSERT``, ``UPDATE``, ``DELETE``, and ``REPLACE`` statements;
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

Expand Down

0 comments on commit bca4b3d

Please sign in to comment.