Documentation Home
Connectors and APIs Manual
Download this Manual
PDF (US Ltr) - 4.1Mb
PDF (A4) - 4.1Mb


6.9.2.29 MySQLConnection.reset_session() Method

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. For MySQL servers 5.7 or higher, the cmd_reset_connection() method is a more lightweight alternative.

This method was added in Connector/Python 1.2.1.