This method sets the character set and collation to be used for
the current connection. The charset argument
can be either the name of a character set, or the numerical
equivalent as defined in
constants.CharacterSet.
When collation is None,
the default is looked up and used.
The charset argument then be either:
In the following example, we set the character set to
latin1 and the collation to
latin1_swedish_ci (the default collation for:
latin1):
>>> cnx = mysql.connector.connect(user='scott')
>>> cnx.set_charset('latin1')
Specify a specific collation as follows:
>>> cnx = mysql.connector.connect(user='scott')
>>> cnx.set_charset('latin1', 'latin1_general_ci')

User Comments
Add your own comment.