Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions Doc/library/sqlite3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -966,18 +966,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`.
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved

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