8000 Add `collation` option and `set_character_set()` to Connection by methane · Pull Request #1119 · PyMySQL/PyMySQL · GitHub
[go: up one dir, main page]

Skip to content

Add collation option and set_character_set() to Connection #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docstring
  • Loading branch information
methane committed May 24, 2023
commit 1d81ded4b9f267c92e9de99a1193d625220d709f
7 changes: 7 additions & 0 deletions pymysql/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,12 @@ def set_charset(self, charset):
self.set_character_set(charset)

def set_character_set(self, charset, collation=None):
"""
Set charaset (and collation)

Send "SET NAMES charset [COLLATE collation]" query.
Update Connection.encoding based on charset.
"""
# Make sure charset is supported.
encoding = charset_by_name(charset).encoding

Expand All @@ -615,6 +621,7 @@ def set_character_set(self, charset, collation=None):
self._read_packet()
self.charset = charset
self.encoding = encoding
self.collation = collation

def connect(self, sock=None):
self._closed = False
Expand Down
0