CBSE Class 12 Computer Science Question 22 of 47

Interface Python with SQL — Question 12

Back to all questions
12
Question

Question 12

Identify the correct statement to create cursor:

import mysql.connector as msq
con = msq.connect()              #ConnectionString
mycursor = ...............
  1. con.cursor()
  2. con.create_cursor()
  3. con.open_cursor()
  4. con.get_cursor()
Answer

con.cursor()

Reason — In MySQL connector for Python, the correct statement to create a cursor is con.cursor(). This method creates and returns a cursor object associated with the connection con, allowing to execute SQL queries.