MySQL :: MySQL Connector/Python Developer Guide :: 10.5 cursor.MySQLCursor Class (original) (raw)
10.5.1 cursor.MySQLCursor Constructor
10.5.2 MySQLCursor.add_attribute() Method
10.5.3 MySQLCursor.clear_attributes() Method
10.5.4 MySQLCursor.get_attributes() Method
10.5.5 MySQLCursor.callproc() Method
10.5.6 MySQLCursor.close() Method
10.5.7 MySQLCursor.execute() Method
10.5.8 MySQLCursor.executemany() Method
10.5.9 MySQLCursor.fetchall() Method
10.5.10 MySQLCursor.fetchmany() Method
10.5.11 MySQLCursor.fetchone() Method
10.5.12 MySQLCursor.nextset() Method
10.5.13 MySQLCursor.fetchsets() Method
10.5.14 MySQLCursor.fetchwarnings() Method
10.5.15 MySQLCursor.stored_results() Method
10.5.16 MySQLCursor.column_names Property
10.5.17 MySQLCursor.description Property
10.5.18 MySQLCursor.warnings Property
10.5.19 MySQLCursor.lastrowid Property
10.5.20 MySQLCursor.rowcount Property
10.5.21 MySQLCursor.statement Property
10.5.22 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 aMySQLConnection
object.
To create a cursor, use thecursor() method of a connection object:
import mysql.connector
cnx = mysql.connector.connect(database='world')
cursor = cnx.cursor()
Several related classes inherit fromMySQLCursor
. To create a cursor of one of these types, pass the appropriate arguments tocursor()
:
MySQLCursorBuffered
creates a buffered cursor. SeeSection 10.6.1, “cursor.MySQLCursorBuffered Class”.
cursor = cnx.cursor(buffered=True)
MySQLCursorRaw
creates a raw cursor. SeeSection 10.6.2, “cursor.MySQLCursorRaw Class”.
cursor = cnx.cursor(raw=True)
MySQLCursorDict
creates a cursor that returns rows as dictionaries. SeeSection 10.6.3, “cursor.MySQLCursorDict Class”.
cursor = cnx.cursor(dictionary=True)
MySQLCursorBufferedDict
creates a buffered cursor that returns rows as dictionaries. SeeSection 10.6.4, “cursor.MySQLCursorBufferedDict Class”.
cursor = cnx.cursor(dictionary=True, buffered=True)
MySQLCursorPrepared
creates a cursor for executing prepared statements. SeeSection 10.6.5, “cursor.MySQLCursorPrepared Class”.
cursor = cnx.cursor(prepared=True)