MySQL Connector/Python Release Notes
In most cases, the MySQLConnection
cursor()
method is used to instantiate a MySQLCursor
object:
Press CTRL+C to copyimport mysql.connector cnx = mysql.connector.connect(database='world') cursor = cnx.cursor()
It is also possible to instantiate a cursor by passing a
MySQLConnection
object to MySQLCursor
:
Press CTRL+C to copyimport mysql.connector from mysql.connector.cursor import MySQLCursor cnx = mysql.connector.connect(database='world') cursor = MySQLCursor(cnx)
The connection argument is optional. If omitted, the cursor is
created but its
execute()
method raises an exception.