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} #加了这一句就好了
}
}
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Django链接mysql数据库报错1064 - Python技术站