Documentation Home
MySQL Connector/Python Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 0.6Mb
PDF (A4) - 0.6Mb
HTML Download (TGZ) - 82.9Kb
HTML Download (Zip) - 95.5Kb


10.2.5 MySQLConnection.connect() Method

Syntax:

MySQLConnection.connect(**kwargs)

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, see Section 7.1, “Connector/Python Connection Arguments”.

Arguments:

  • kwargs: Connection arguments.

Example:

cnx = MySQLConnection(user='joe', database='test')

For a connection obtained from a conection pool, the connection object class is PooledMySQLConnection. A pooled connection differs from an unpooled connection as described in Section 9.1, “Connector/Python Connection Pooling”.


User Comments
User comments in this section are, as the name implies, provided by MySQL users. The MySQL documentation team is not responsible for, nor do they endorse, any of the information provided here.
  Posted by Paris Nakita Kejser on November 4, 2015
There need a simple doc here about this, so here its comming more to connect to remove host and with password you need to connect this way

cnx = mysql.connector.connect(user='user', password='pass', host='hostname', database='db name')
Sign Up Login You must be logged in to post a comment.