mirror of
https://github.com/python/cpython.git
synced 2025-09-17 22:20:23 +00:00
sqlite3: Fix documentation errors concerning Cursor.rowcount
Closes #13995.
This commit is contained in:
parent
f670ca5e70
commit
b3890226b3
3 changed files with 8 additions and 10 deletions
|
@ -17,5 +17,4 @@ con.executemany("insert into person(firstname, lastname) values (?, ?)", persons
|
||||||
for row in con.execute("select firstname, lastname from person"):
|
for row in con.execute("select firstname, lastname from person"):
|
||||||
print(row)
|
print(row)
|
||||||
|
|
||||||
# Using a dummy WHERE clause to not let SQLite take the shortcut table deletes.
|
print("I just deleted", con.execute("delete from person").rowcount, "rows")
|
||||||
print("I just deleted", con.execute("delete from person where 1=1").rowcount, "rows")
|
|
||||||
|
|
|
@ -543,18 +543,17 @@ Cursor Objects
|
||||||
attribute, the database engine's own support for the determination of "rows
|
attribute, the database engine's own support for the determination of "rows
|
||||||
affected"/"rows selected" is quirky.
|
affected"/"rows selected" is quirky.
|
||||||
|
|
||||||
For ``DELETE`` statements, SQLite reports :attr:`rowcount` as 0 if you make a
|
|
||||||
``DELETE FROM table`` without any condition.
|
|
||||||
|
|
||||||
For :meth:`executemany` statements, the number of modifications are summed up
|
For :meth:`executemany` statements, the number of modifications are summed up
|
||||||
into :attr:`rowcount`.
|
into :attr:`rowcount`.
|
||||||
|
|
||||||
As required by the Python DB API Spec, the :attr:`rowcount` attribute "is -1 in
|
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
|
case no ``executeXX()`` has been performed on the cursor or the rowcount of the
|
||||||
last operation is not determinable by the interface".
|
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.
|
||||||
|
|
||||||
This includes ``SELECT`` statements because we cannot determine the number of
|
With SQLite versions before 3.6.5, :attr:`rowcount` is set to 0 if
|
||||||
rows a query produced until all rows were fetched.
|
you make a ``DELETE FROM table`` without any condition.
|
||||||
|
|
||||||
.. attribute:: Cursor.lastrowid
|
.. attribute:: Cursor.lastrowid
|
||||||
|
|
||||||
|
|
|
@ -528,8 +528,8 @@ Extension Modules
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- Issue #13491: Fix many errors in sqlite3 documentation. Initial
|
- Issues #13491 and #13995: Fix many errors in sqlite3 documentation.
|
||||||
patch by Johannes Vogel.
|
Initial patch for #13491 by Johannes Vogel.
|
||||||
|
|
||||||
- Issue #13402: Document absoluteness of sys.executable.
|
- Issue #13402: Document absoluteness of sys.executable.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue