reconnect()

Tries to make a connection object active again by reconnecting to the server using the same credentials which were specified in connect() method.

See also: MariaDB Connector/Python 1.0

EXAMPLES

import mariadb

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

cursor = conn.cursor()

# ... assume the connection dies while other things are going on ...

try:
    conn.ping()
except mariadb.DatabaseError:
    conn.reconnect()

# ... feel free to use the cursor ...