Updated on 2025-10-23 GMT+08:00

connection.set_character_set(charset, collation=None)

Description

This method sets the character set and collation of the database connection.

The character sets of the client and server must be the same. Otherwise, an error is reported.

Prototype

connection.set_character_set(charset, collation=None)

Parameters

Table 1 connection.set_character_set(charset, collation=None)

Keyword

Description

charset

Character set of the database connection.

collation

Collation of the database connection. The default value is None.

Return Value

None

Examples

For details, see Examples: Common Operations.