发布时间:2019-09-25 08:20:07编辑:auto阅读(1837)
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
48452
47338
38222
35464
29922
26627
25601
20546
20240
18666
61°
72°
174°
124°
146°
261°
337°
332°
309°
400°