9.2.29 Method MySQLConnection.reset_session()

Syntax:

cnx.reset_session(user_variables = None, session_variables = None)

Resets the connection by reauthenticating to clear the session state. user_variables, if given, is a dictionary of user variable names and values. session_variables, if given, is a dictionary of system variable names and values. The method sets each variable to the given value.

Example:

user_variables = {'var1': '1', 'var2': '10'}
session_variables = {'wait_timeout': 100000, 'sql_mode': 'TRADITIONAL'}
self.cnx.reset_session(user_variables, session_variables)

This method resets the session state by reauthenticating, which is expensive. For MySQL servers 5.7.3 or later, the cmd_reset_connection() method can be used instead. It is more lightweight because it permits the session state to be cleared without reauthenticating.

This method was added in Connector/Python 1.2.1.