Pycharm MySQL connection steps and Precautions

1. Modify the database connection MySQL:
  Default: MySQLDB #MySQLDB only support Python2, does not support python3, so to be amended,
  modified: pymysql, all you need to import the module pymysql each project,
  modification method: In the Project Folder Alternatively the __init__.py introduced pymysql MySQLdb follows:
  import pymysql
  pymysql.install_as_MySQLdb ()

2. sqlite3 database to replace the original settings / py as follows:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'Upload_Files',
'USER': 'root',
'PASSWORD': '123123',
'HOST': '',
'PORT': '3306',
}
}


3. Since the version of the problem: commented: lib \ site-packages \ django \ db \ backends \ mysql \ base.py in

if version < (1, 3, 13):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)


4. Then: lib \ site-packages \ django \ db \ backends \ mysql \ operations.py decode line 146 into encode

5. The terminal creates a database (or use an existing database)
6. Execute the following code in a terminal
python3 manage makemigrations .py
python3 manage.py the migrate

Guess you like

Origin www.cnblogs.com/yangyangming/p/10956733.html