Django 3.0 connection mysql 8.0, may not be used pymysql, you can upgrade Mysqlclient

in python, mysql connection is generally recommended pymysql, but also in django, the online tutorials are so connected mysql.

import pymysql

pymysql.install_as_MySQLdb()

This is actually pymysql module calls a function install_as_MySQLdb module (), this function annotation says so.

After this function is called, any application that imports MySQLdb or
_mysql will unwittingly actually use pymysql.

Probably it means:

  After calling this function, or any MySQLdb _mysql introduced applications are actually used pymysql inadvertently.

Since django actual call is MySQLdb, recently in use Django 3.0, the time of import MySQLdbl of error, suggesting Mysqlclient version of the problem, I installed the latest version of MySQLdb, the version number is 1.4.6, then import MySQLdb success, I successfully connected the MySQL, my local installation is MySQL8.0, the connection is successful, used to practice ORM operations in Django and found no problems. I have not tested Mysql5.5 5.6 5.7 version. I guess no problem,

It seems the old methods of the possibility OUT.

Release for your reference, if you have version compatibility problems, but also take the trouble to post a message in this for everyone to share.

Guess you like

Origin www.cnblogs.com/worldinmyeyes/p/12093495.html
Recommended