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


10.2.4 MySQLConnection.config() Method

Syntax:

cnx.config(**kwargs)

Configures a MySQLConnection instance after it has been instantiated. For a complete list of possible arguments, see Section 7.1, “Connector/Python Connection Arguments”.

Arguments:

  • kwargs: Connection arguments.

You could use the config() method to change (for example) the user name, then call reconnect().

Example:

cnx = mysql.connector.connect(user='joe', database='test')
# Connected as 'joe'
cnx.config(user='jane')
cnx.reconnect()
# Now connected as 'jane'

For a connection obtained from a connection pool, config() raises an exception. See Section 9.1, “Connector/Python Connection Pooling”.


User Comments
Sign Up Login You must be logged in to post a comment.