数据库
首页 > 数据库> > [转] **Python错误记录:' pymysql KeyError:255'**

[转] **Python错误记录:' pymysql KeyError:255'**

作者:互联网

Traceback (most recent call last): ... File "C:\Program Files\Python36\lib\site-packages\pymysql\__init__.py", line 90, in Connect return Connection(*args, **kwargs) File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 706, in __init__ self.connect() File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 931, in connect self._get_server_information() File "C:\Program Files\Python36\lib\site-packages\pymysql\connections.py", line 1269, in _get_server_information self.server_charset = charset_by_id(lang).name File "C:\Program Files\Python36\lib\site-packages\pymysql\charset.py", line 38, in by_id return self._by_id[id] KeyError: 255

主要原因是MySQL8.0更新了很多字符集,但是这些字符集长度超过255了,所以旧版的PyMySQL不支持长度超过255的字符
解决方法, 更新PyMySQL:

pip install --upgrade PyMySQL

标签:Files,lib,Python,py,KeyError,pymysql,site,Program
来源: https://blog.csdn.net/wccms/article/details/104909347