Syntax:
ccnx = _mysql_connector.MySQL(args)
The MySQL
class is used to open and manage a
connection to a MySQL server (referred to elsewhere in this
reference as “the MySQL
instance”). It is also used to send commands and SQL
statements and read results.
The MySQL
class wraps most functions found in
the MySQL C Client API and adds some additional convenient
functionality.
import _mysql_connector
ccnx = _mysql_connector.MySQL()
ccnx.connect(user='scott', password='password',
host='127.0.0.1', database='employees')
ccnx.close()
Permitted arguments for the MySQL
class are
auth_plugin
, buffered
,
charset_name
,
connection_timeout
, raw
,
use_unicode
. Those arguments correspond to the
arguments of the same names for
MySQLConnection.connect()
as described at
Section 7.1, “Connector/Python Connection Arguments”, except that
charset_name
corresponds to
charset
.