.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.
在仔细研究了源代码之后,下面是相关的代码行(MySQLdb/光标.py:120)在
因此
rowcount
只是Cursor
类的一个成员变量(不是一个方法),它恰好保存了affected_rows
的结果。我想它可能会帮你省去对那个特定函数的调用。在我发现MySQLDB上的tutorial很有用。Rowcount被提到,但没有在其中一个示例中使用。在
Python数据库模块文档的主要来源是the DB-API 2.0 specification:
相关问题 更多 >
编程相关推荐