本人用peewee进行mysql语句报了一下错误(警告)
Warning: (3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated.
It will be removed in a future release.") result = self._query(query)
set @@GLOBAL.sql_mode='';
set sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
set @@sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
在 [mysqld]和[mysql]下添加
sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
使用django出现这个问题
/venv3.5/lib/python3.5/site-packages/pymysql/cursors.py:170: Warning:
(3135, "'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO'
sql modes should be used with strict mode.
They will be merged with strict mode in a future release.")
result = self._query(query)
/venv3.5/lib/python3.5/site-packages/pymysql/cursors.py:170: Warning:
(3090, "Changing sql mode 'NO_AUTO_CREATE_USER' is deprecated.
It will be removed in a future release.")
result = self._query(query)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
...,
'OPTIONS': {
'init_command': "SET sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER'",
'charset': 'utf8mb4'
},
}