cursor = cnx.cursor([arg=value[, arg=value]...])
This method returns a
or a subclass of it depending on the passed arguments. The
returned object is a
instance. For more information about cursor objects, see
Section 6.9.5, “cursor.MySQLCursor Class”, and
Section 6.9.6, “Subclasses cursor.MySQLCursor”.
Arguments may be passed to the
method to control what type of cursor to create:
True, the cursor fetches all rows from the server after an operation is executed. This is useful when queries return small result sets.
bufferedcan be used alone, or in combination with the
bufferedcan also be passed to
connect()to set the default buffering mode for all cursors created from the connection object. See Section 6.7.1, “Connector/Python Connection Arguments”.
For information about the implications of buffering, see Section 126.96.36.199, “cursor.MySQLCursorBuffered Class”.
True, the cursor skips the conversion from MySQL data types to Python types when fetching rows. A raw cursor is usually used to get better performance or when you want to do the conversion yourself.
rawcan also be passed to
connect()to set the default raw mode for all cursors created from the connection object. See Section 6.7.1, “Connector/Python Connection Arguments”.
True, the cursor returns rows as dictionaries. This argument is available as of Connector/Python 2.0.0.
True, the cursor returns rows as named tuples. This argument is available as of Connector/Python 2.0.0.
True, the cursor is used for executing prepared statements. This argument is available as of Connector/Python 1.1.2. The C extension supports this as of Connector/Python 8.0.17.
cursor_classargument can be used to pass a class to use for instantiating a new cursor. It must be a subclass of
The returned object depends on the combination of the arguments. Examples:
If not buffered and not raw:
If buffered and not raw:
If not buffered and raw:
If buffered and raw: