Solve the problem of pychart connecting MySQL 1366 and reporting an error

If you use pymysql to connect to MySQL, an error 1366 will be reported

engine=create_engine('mysql+pymysql://root:1234@localhost/b',#Specify the database engine to connect to, e.g. MySQL, Oracle, etc.
                     encoding='utf-8',
                     echo=False)

Error reporting:

E:\Anacoda\lib\site-packages\pymysql\cursors.py:170: Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 497")
  result = self._query(query)

Solution

Download MySQL connector Python from the official MySQL website: https://dev.mysql.com/downloads/connector/python/

After downloading and installing, change pymysql in the original connection code to mysqlconnector

engine=create_engine('mysql+mysqlconnector://root:1234@localhost/b',
                     encoding='utf-8',
                     echo=False)

 

Similar Posts: