- 10.5.1 cursor.MySQLCursor构造函数
- 10.5.2 MySQLCursor.callproc()方法
- 10.5.3 MySQLCursor.close()方法
- 10.5.4 MySQLCursor.execute()方法
- 10.5.5 MySQLCursor.executemany()方法
- 10.5.6 MySQLCursor.fetchall()方法
- 10.5.7 MySQLCursor.fetchmany()方法
- 10.5.8 MySQLCursor.fetchone()方法
- 10.5.9 MySQLCursor.fetchwarnings()方法
- 10.5.10 MySQLCursor.stored_results()方法
- 10.5.11 MySQLCursor.column_names 属性
- 10.5.12 MySQLCursor.description 属性
- 10.5.13 MySQLCursor.lastrowid 属性
- 10.5.14 MySQLCursor.rowcount 属性
- 10.5.15 MySQLCursor.statement 属性
- 10.5.16 MySQLCursor.with_rows 属性
该类MySQLCursor实例化了可以执行 SQL 语句等操作的对象。游标对象使用对象与 MySQL 服务器交互
MySQLConnection。
要创建游标,请使用
cursor()
连接对象的方法:
import mysql.connector
cnx = mysql.connector.connect(database='world')
cursor = cnx.cursor()
几个相关的类继承自
MySQLCursor. 要创建这些类型之一的游标,请将适当的参数传递给
cursor():
-
MySQLCursorBuffered创建一个缓冲游标。请参阅 第 10.6.1 节,“cursor.MySQLCursorBuffered 类”。cursor = cnx.cursor(buffered=True) -
MySQLCursorRaw创建一个原始游标。参见 第 10.6.2 节,“cursor.MySQLCursorRaw 类”。cursor = cnx.cursor(raw=True) -
MySQLCursorBufferedRaw创建一个缓冲的原始游标。参见 第 10.6.3 节,“cursor.MySQLCursorBufferedRaw 类”。cursor = cnx.cursor(raw=True, buffered=True) -
MySQLCursorDict创建一个将行作为字典返回的游标。参见 第 10.6.4 节,“cursor.MySQLCursorDict 类”。cursor = cnx.cursor(dictionary=True) -
MySQLCursorBufferedDict创建一个缓冲游标,将行作为字典返回。参见 第 10.6.5 节,“cursor.MySQLCursorBufferedDict 类”。cursor = cnx.cursor(dictionary=True, buffered=True) -
MySQLCursorNamedTuple创建一个以命名元组形式返回行的游标。参见 第 10.6.6 节,“cursor.MySQLCursorNamedTuple 类”。cursor = cnx.cursor(named_tuple=True) -
MySQLCursorBufferedNamedTuple创建一个缓冲游标,它以命名元组的形式返回行。参见 第 10.6.7 节,“cursor.MySQLCursorBufferedNamedTuple 类”。cursor = cnx.cursor(named_tuple=True, buffered=True) -
MySQLCursorPrepared创建用于执行准备好的语句的游标。参见 第 10.6.8 节,“cursor.MySQLCursorPrepared Class”。cursor = cnx.cursor(prepared=True)