Question why

Django uses MySQLdb as the default driver when connecting to MySQL, but MySQLdb does not support Python3

Problem solving

Installation:

python3 -m pip install pymysql
Copy the code

Use:

import pymysql
pymysql.install_as_MySQLdb()
Copy the code

The correct version

Django. Core. Exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; You have 0.9.3.Copy the code

Method 1:

import pymysql
pymysql.version_info = (1.4.6.'final'.0)  # change mysqlclient version
pymysql.install_as_MySQLdb()
Copy the code

Method 2: find python installation package under the path of site – packages/django/db/backends/mysql/base. Py files, comment out the following contents:

if version < (1.3.13) :raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
Copy the code








Youth is a bookmark, loaded the most painful page — from the network