- 10.5.1 cursor.MySQLCursor 建構子
- 10.5.2 MySQLCursor.add_attribute() 方法
- 10.5.3 MySQLCursor.clear_attributes() 方法
- 10.5.4 MySQLCursor.get_attributes() 方法
- 10.5.5 MySQLCursor.callproc() 方法
- 10.5.6 MySQLCursor.close() 方法
- 10.5.7 MySQLCursor.execute() 方法
- 10.5.8 MySQLCursor.executemany() 方法
- 10.5.9 MySQLCursor.fetchall() 方法
- 10.5.10 MySQLCursor.fetchmany() 方法
- 10.5.11 MySQLCursor.fetchone() 方法
- 10.5.12 MySQLCursor.fetchwarnings() 方法
- 10.5.13 MySQLCursor.stored_results() 方法
- 10.5.14 MySQLCursor.column_names 屬性
- 10.5.15 MySQLCursor.description 屬性
- 10.5.16 MySQLCursor.lastrowid 屬性
- 10.5.17 MySQLCursor.rowcount 屬性
- 10.5.18 MySQLCursor.statement 屬性
- 10.5.19 MySQLCursor.with_rows 屬性
MySQLCursor 類別會實例化可執行 SQL 陳述式等操作的物件。游標物件會使用 MySQLConnection 物件與 MySQL 伺服器互動。
若要建立游標,請使用連線物件的 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 類別」。cursor = cnx.cursor(prepared=True)