Which method of cursor class is used to get the number of rows affected after any of the insert/ update/delete database operation executed from Python?
(A) cursor.rowcount
(B) cursor.getaffectedcount
(C) cursor.rowscount
(D) cursor.rcount
Answer:
Checking the options
- (A) cursor.rowcount - It returns the number of rows affected by DML statements.
- (B) cursor.getaffectedcount - It is not a method of cursor class.
- (C) cursor.rowscount - It is not a method of cursor class.
- (D) cursor.rcount - It is not a method of cursor class.
From the options given above, the function cursor.rowcount is used to get the number of rows affected after any of the insert/update/delete database operations executed from Python.
So, the correct answer is (A)