Skip to content

Commit

Permalink
fix KeyError when server reports unknown collation
Browse files Browse the repository at this point in the history
fixes #591
  • Loading branch information
methane committed Aug 21, 2017
1 parent 5298017 commit 4b7e9c9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pymysql/connections.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1266,8 +1266,14 @@ def _get_server_information(self):
if len(data) >= i + 6: if len(data) >= i + 6:
lang, stat, cap_h, salt_len = struct.unpack('<BHHB', data[i:i+6]) lang, stat, cap_h, salt_len = struct.unpack('<BHHB', data[i:i+6])
i += 6 i += 6
# TODO: deprecate server_language and server_charset.
# mysqlclient-python doesn't provide it.
self.server_language = lang self.server_language = lang
self.server_charset = charset_by_id(lang).name try:
self.server_charset = charset_by_id(lang).name
except KeyError:
# unknown collation
self.server_charset = None


self.server_status = stat self.server_status = stat
if DEBUG: print("server_status: %x" % stat) if DEBUG: print("server_status: %x" % stat)
Expand Down

2 comments on commit 4b7e9c9

@TaoReStar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have the problem

@alifsyfulislam
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still have the problem

Please sign in to comment.