Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b389022

Browse files
committed
sqlite3: Fix documentation errors concerning Cursor.rowcount
Closes #13995.
1 parent f670ca5 commit b389022

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

Doc/includes/sqlite3/shortcut_methods.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,4 @@
1717
for row in con.execute("select firstname, lastname from person"):
1818
print(row)
1919

20-
# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
21-
print("I just deleted", con.execute("delete from person where 1=1").rowcount, "rows")
20+
print("I just deleted", con.execute("delete from person").rowcount, "rows")

Doc/library/sqlite3.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,17 @@ Cursor Objects
543543
attribute, the database engine's own support for the determination of "rows
544544
affected"/"rows selected" is quirky.
545545

546-
For ``DELETE`` statements, SQLite reports :attr:`rowcount` as 0 if you make a
547-
``DELETE FROM table`` without any condition.
548-
549546
For :meth:`executemany` statements, the number of modifications are summed up
550547
into :attr:`rowcount`.
551548

552549
As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
553550
case no ``executeXX()`` has been performed on the cursor or the rowcount of the
554-
last operation is not determinable by the interface".
551+
last operation is not determinable by the interface". This includes ``SELECT``
552+
statements because we cannot determine the number of rows a query produced
553+
until all rows were fetched.
555554

556-
This includes ``SELECT`` statements because we cannot determine the number of
557-
rows a query produced until all rows were fetched.
555+
With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
556+
you make a ``DELETE FROM table`` without any condition.
558557

559558
.. attribute:: Cursor.lastrowid
560559

Misc/NEWS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ Extension Modules
528528
Documentation
529529
-------------
530530

531-
- Issue #13491: Fix many errors in sqlite3 documentation. Initial
532-
patch by Johannes Vogel.
531+
- Issues #13491 and #13995: Fix many errors in sqlite3 documentation.
532+
Initial patch for #13491 by Johannes Vogel.
533533

534534
- Issue #13402: Document absoluteness of sys.executable.
535535

0 commit comments

Comments
 (0)