Skip to content Skip to sidebar Skip to footer

Python Mysqldb Documentation Missing Details?

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) actua

Solution 1:

The primary source of documentation for Python database modules is the DB-API 2.0 specification:

.rowcount 

       This read-only attribute specifies the number ofrows that
        the last .execute*() produced (for DQL statements like'select') or affected (for DML statements like'update'or'insert').

       The attribute is-1incaseno .execute*() has been
        performed on the cursoror 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 caseto have the object returnNone
        instead of-1.

Solution 2:

I found this tutorial on MySQLDB useful. Rowcount is mentioned, but not used in one of the examples.

Solution 3:

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.

Solution 4:

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.

Post a Comment for "Python Mysqldb Documentation Missing Details?"