Django链接mysql数据库报错1064

D:\PycharmProjects\autotest>python manage.py makemigrations

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syn
tax to use near 'SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED' at line
1")

 

 在autotest目录的__init__.py 已经添加以下两行:

import pymysql
pymysql.install_as_MySQLdb()


settings.py中修改为如下内容:
DATABASES = {
'default':
{
'ENGINE': 'django.db.backends.mysql',
'NAME': 'autotest',
'USER': 'root',
'PASSWORD': '123456',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {'isolation_level': None}
}
}
--------------------------------------------------

DATABASES = {
'default':
{
'ENGINE': 'django.db.backends.mysql',
'NAME': 'autotest',
'USER': 'root',
'PASSWORD': '123456',
'HOST': '127.0.0.1',
'PORT': '3306',
'OPTIONS': {'isolation_level': None} #加了这一句就好了
}
}



posted @ 2019-06-10 23:10  feiyueNotes  阅读(1890)  评论(0编辑  收藏  举报