In MySQL-Python connectivity, after executing a SELECT query using a cursor…
2026
In MySQL-Python connectivity, after executing a SELECT query using a cursor object, which attribute or method is used to determine the number of rows fetched or returned by the most recently executed query?
- A.
count()
- B.
count(*)
- C.
rowcount
- D.
rowcount()
Attempted by 504 students.
Show answer & explanation
Correct answer: C
The correct answer is Option C (rowcount).
In MySQL-Python connectivity, after executing a SELECT query using a cursor object, the rowcount attribute is used to determine the number of rows fetched or returned by the query. It is an attribute, not a method, so it is used without parentheses.
Example:
cursor.execute("SELECT * FROM table")
print(cursor.rowcount)
Thus, rowcount gives the number of rows returned by the last executed query.