MySQL Connector/Python 發行說明
MySQLCursorRaw
類別繼承自 MySQLCursor
。
當提取資料列時,MySQLCursorRaw
游標會略過將 MySQL 資料類型轉換為 Python 類型的步驟。原始游標通常用於獲得更好的效能,或者當您想自己進行轉換時。
要建立原始游標,請在呼叫連線的 cursor()
方法時使用 raw
引數。或者,若要使從連線建立的所有游標預設為原始游標,請使用 raw
連線引數。
範例
import mysql.connector
cnx = mysql.connector.connect()
# Only this particular cursor will be raw
cursor = cnx.cursor(raw=True)
# All cursors created from cnx2 will be raw by default
cnx2 = mysql.connector.connect(raw=True)