MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / connection.MySQLConnection Class / MySQLConnection.config() Method
Syntax:
cnx.config(**kwargs) Configures aMySQLConnection instance after it has been instantiated. For a complete list of possible arguments, seeSection 7.1, “Connector/Python Connection Arguments”.
Arguments:
kwargs: Connection arguments.
You could use theconfig() method to change (for example) the user name, then callreconnect().
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. SeeSection 9.5, “Connector/Python Connection Pooling”.