rowcount

Overview

Provides the number of rows returned by the last query. (read-only)

See also: MariaDB Connector/Python 1.1 and in 1.0

EXAMPLES

import mariadb

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

cursor = conn.cursor()

cursor.execute("UPDATE sample SET name = 'new' WHERE name = 'foo'")
if cursor.rowcount > 0:
    print('Updated rows:', cursor.rowcount)
else: # rowcount == -1
    print('The update made no changes.')

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.