scroll()

Overview

Scrolls the cursor in the result-set to a new position according to mode.

See also: MariaDB Connector/Python 1.1 and in 1.0

DETAILS

Scroll the cursor in the result set to a new position. A mode arg specifies if the numeric skip value is either "relative" to the current record (the default) or "absolute" with a 0-relative row number.

EXAMPLES

import mariadb

conn = mariadb.connect(
    host = 'localhost',
    user = 'root',
    password = 'secret',
    database = 'test',
    )

cursor = conn.cursor()

cursor.execute("SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4", buffered=True)

print("The rows should appear in this order: 1, 4, 3, 2")

row_1 = cursor.fetchone()
print(row_1)

cursor.scroll(2)

row_4 = cursor.fetchone()
print(row_4)

cursor.scroll(2, 'absolute')

row_3 = cursor.fetchone()
print(row_3)

cursor.scroll(-2)

row_2 = cursor.fetchone()
print(row_2)

CHANGE HISTORY

Release Series

History

1.1

  • Present starting in MariaDB Connector/Python 1.1.2.

1.0

  • Present starting in MariaDB Connector/Python 1.0.0.