发布时间:2019-09-25 08:20:07编辑:auto阅读(2401)
pymysql 连接Inception ,在判断版本时会出现value error 问题。
原因是pymysql通过‘.’进行分割,但是Inception的版本信息是这样的
./mysql -V
Ver 14.14 Distrib Inception2.1.50, for Linux (x86_64) using EditLine wrapper
oracle mysql的版本是:
mysql Ver 14.14 Distrib 5.7.18, for Linux (x86_64) using EditLine wrapper
因此Pymysql获取到的值为Inception2,最后int() 报value error。
可以简单修改pymysql connections.py(只是解决了问题,对具体代码还不是很了解)
def _request_authentication(self):
# https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse
if self.server_version.split('.', 1)[0] == 'Inception2':
self.client_flag |= CLIENT.MULTI_RESULTS
elif int(self.server_version.split('.', 1)[0]) >= 5:
self.client_flag |= CLIENT.MULTI_RESULTS;
使用Pymysql connection配置可以是下面这样
conn = pymysql.connect(host='127.0.0.1', user='', passwd='', db='', port=6669, autocommit=True, cursorclass=pymysql.cursors.DictCursor, charset='utf8mb4' )
上一篇: Python3网络爬虫实战-28、解析库
下一篇: Python3网络爬虫实战-16、Web
51929
51701
42019
38857
33345
30315
28955
23970
23885
22251
381°
2588°
3261°
2713°
2701°
3429°
2657°
3495°
5765°
5537°