I am trying to make sense of MySQLdb documentation. I was just wondering if there are things missing from there. For example, I am trying to see what "rowcount" (a constant) actually does, but am not seeing it anywhere in the documentation.
So is the documentation incomplete or am I just looking at the wrong place?
Thanks.
The primary source of documentation for Python database modules is the DB-API 2.0 specification:
.rowcount
This read-only attribute specifies the number of rows that
the last .execute*() produced (for DQL statements like
'select') or affected (for DML statements like 'update' or
'insert').
The attribute is -1 in case no .execute*() has been
performed on the cursor or the rowcount of the last
operation is cannot be determined by the interface. [7]
Note: Future versions of the DB API specification could
redefine the latter case to have the object return None
instead of -1.
I found this tutorial on MySQLDB useful. Rowcount is mentioned, but not used in one of the examples.
Well after poring through the source code, here's the relevant line (MySQLdb/cursors.py:120)
self.rowcount = db.affected_rows()
So rowcount
is just a member variable for the Cursor
class (not a method), which happens to hold the result of affected_rows
. I guess it probably saves you a call to that particular function.
I used the following google search: rowcount site:mysql-python.sourceforge.net
It is often better to use google site:
operator to search a site than to use the site's native search. But your right, it doesn't have it's own documentation.