Python 3 connection inception problem with Pymysql

Source: Internet
Author: User
Tags wrapper

Pymysql connection inception, the value error problem occurs when judging the version.

The reason is that pymysql through '. ' Split, but the inception version information is like this

./mysql-v

Ver 14.14 Distrib Inception2.1.50, for Linux (x86_64) using Editline Wrapper

The version of Oracle MySQL is:

MySQL Ver 14.14 distrib 5.7.18, for Linux (x86_64) using Editline Wrapper


So Pymysql gets the value to Inception2, and the last int is quoted as value error.


You can simply modify the Pymysql connections.py (just to solve the problem, but not very familiar with the specific code)

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

Using the Pymysql connection configuration can be the following

conn = Pymysql.connect (host= ' 127.0.0.1 ', user= ', passwd= ', db= ', port=6669, Autocommit=true, cursorclass=pymysql.cursors.dictcursor, charset= ' u Tf8mb4 ')


Python 3 using Pymysql connection inception problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.