Computer Science
Identify the correct statement to create cursor:
import mysql.connector as msq
con = msq.connect() #ConnectionString
mycursor = ...............
- con.cursor()
- con.create_cursor()
- con.open_cursor()
- con.get_cursor()
Python MySQL
2 Likes
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.
Answered By
3 Likes
Related Questions
Which command is used for cleaning up the environment?
- my.closed()
- is.end()
- con.quit()
- mycon.close()
Which function of connection is used to check whether connection to MySQL is successfully done or not?
import mysql.connector as mycon con = mycon.connect #ConnectionString if ...............: print("Connected!") else: print("Error! Not Connected")- con.connected()
- con.isconnected()
- con.is_connected()
- con.is_connect()
Explain the following 'results' retrieval methods with examples.
(a) fetchone()
(b) rowcount
(c) fetchall()
What is the significance of connecting Python with MySQL?