MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / mysql.connector Module / mysql.connector.connect() Method
This method sets up a connection, establishing a session with the MySQL server. If no arguments are given, it uses the already configured or default values. For a complete list of possible arguments, seeSection 7.1, “Connector/Python Connection Arguments”.
A connection with the MySQL server can be established using either themysql.connector.connect() method or themysql.connector.MySQLConnection() class:
cnx = mysql.connector.connect(user='joe', database='test')cnx = MySQLConnection(user='joe', database='test')For descriptions of connection methods and properties, seeSection 10.2, “connection.MySQLConnection Class”.