Returns a new cursor object for the current connection.

See also: MariaDB Connector/Python 1.0


Supported parameters:


When set to True, each fetched row is returned as a named tuple instead of a normal tuple. This allows you to access the column values using either the name of the column ( or its index position (row[0]).


When set to mariadb.CURSOR_TYPE_READ_ONLY a read-only cursor is created, which does not allow any changes to be made to the database.


The number of rows prefetched. This option is ignored if the cursor_type is not CURSOR_TYPE_READ_ONLY.


When set to True the entire result set from a SELECT/SHOW statement is stored in client memory.


When set to True the cursor remains in a prepared state after the first execute() method is called. Further calls to execute() ignore the sql statement. This means that you will need to create a separate cursor for each statement you wish to execute.


The following gives you a cursor object that you can then use to execute() SQL statements:

import mariadb

conn = mariadb.connect(
    host = '',
    user = 'root',
    password = 'secret',

cursor = conn.cursor()

If you want to have the option of accessing the row data using column names (in addition to tuple index integers) change the cursor assignment to pass in the named_tuple option:

cursor = conn.cursor(named_tuple=True)