- 6.9.5.1 cursor.MySQLCursor Constructor
- 6.9.5.2 MySQLCursor.add_attribute() Method
- 6.9.5.3 MySQLCursor.clear_attributes() Method
- 6.9.5.4 MySQLCursor.get_attributes() Method
- 6.9.5.5 MySQLCursor.callproc() Method
- 6.9.5.6 MySQLCursor.close() Method
- 6.9.5.7 MySQLCursor.execute() Method
- 6.9.5.8 MySQLCursor.executemany() Method
- 6.9.5.9 MySQLCursor.fetchall() Method
- 6.9.5.10 MySQLCursor.fetchmany() Method
- 6.9.5.11 MySQLCursor.fetchone() Method
- 6.9.5.12 MySQLCursor.fetchwarnings() Method
- 6.9.5.13 MySQLCursor.stored_results() Method
- 6.9.5.14 MySQLCursor.column_names Property
- 6.9.5.15 MySQLCursor.description Property
- 6.9.5.16 MySQLCursor.lastrowid Property
- 6.9.5.17 MySQLCursor.rowcount Property
- 6.9.5.18 MySQLCursor.statement Property
- 6.9.5.19 MySQLCursor.with_rows Property
The MySQLCursor
class instantiates objects that
can execute operations such as SQL statements. Cursor objects
interact with the MySQL server using a
MySQLConnection
object.
To create a cursor, use the
cursor()
method of a connection object:
import mysql.connector
cnx = mysql.connector.connect(database='world')
cursor = cnx.cursor()
Several related classes inherit from
MySQLCursor
. To create a cursor of one of these
types, pass the appropriate arguments to
cursor()
:
MySQLCursorBuffered
creates a buffered cursor. See Section 6.9.6.1, “cursor.MySQLCursorBuffered Class”.cursor = cnx.cursor(buffered=True)
MySQLCursorRaw
creates a raw cursor. See Section 6.9.6.2, “cursor.MySQLCursorRaw Class”.cursor = cnx.cursor(raw=True)
MySQLCursorBufferedRaw
creates a buffered raw cursor. See Section 6.9.6.3, “cursor.MySQLCursorBufferedRaw Class”.cursor = cnx.cursor(raw=True, buffered=True)
MySQLCursorDict
creates a cursor that returns rows as dictionaries. See Section 6.9.6.4, “cursor.MySQLCursorDict Class”.cursor = cnx.cursor(dictionary=True)
MySQLCursorBufferedDict
creates a buffered cursor that returns rows as dictionaries. See Section 6.9.6.5, “cursor.MySQLCursorBufferedDict Class”.cursor = cnx.cursor(dictionary=True, buffered=True)
MySQLCursorNamedTuple
creates a cursor that returns rows as named tuples. See Section 6.9.6.6, “cursor.MySQLCursorNamedTuple Class”.cursor = cnx.cursor(named_tuple=True)
MySQLCursorBufferedNamedTuple
creates a buffered cursor that returns rows as named tuples. See Section 6.9.6.7, “cursor.MySQLCursorBufferedNamedTuple Class”.cursor = cnx.cursor(named_tuple=True, buffered=True)
MySQLCursorPrepared
creates a cursor for executing prepared statements. See Section 6.9.6.8, “cursor.MySQLCursorPrepared Class”.cursor = cnx.cursor(prepared=True)