Which method of cursor class is used to insert or update multiple rows using a single query?
(A) cursor.executeall(query, rows)
(B) cursor.execute(query, rows)
(C) cursor.executemultiple (query, rows)
(D) cursor.executemany(query, rows)
Answer:
Checking the options:
- (A) cursor.executeall(query, rows) - It is not a method of cursor class.
- (B) cursor.execute(query, rows) - It executes the given SQL statement.
- (C) cursor.executemultiple (query, rows) - It is not a method of cursor class.
- (D) cursor.executemany(query, rows) - It executes more than one SQL statement together.
From the options given above, the function cursor.executemany(query, rows) is used to insert or update multiple rows using a single query
So, the correct answer is (D)