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():

cursor = cnx.cursor(buffered=True)  
cursor = cnx.cursor(raw=True)  
cursor = cnx.cursor(dictionary=True)  
cursor = cnx.cursor(dictionary=True, buffered=True)  
cursor = cnx.cursor(prepared=True)