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)

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.