reconnect()
This page is part of MariaDB's Enterprise Documentation.
The parent of this page is: Connector/Python API
Topics on this page:
Overview
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.1 and in 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 ...
CHANGE HISTORY
Release Series | History |
---|---|
1.1 |
|
1.0 |
|