仍然将sql_mode强制为“ STRICT_TRANS_TABLES”仍然警告Django

时间:2019-07-06 09:09:13

标签: python mysql django pymysql

我正在使用Django 2.1.3pymysql 0.9.2mysql 5.7python3.5

sql_mode in mysql:

ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

db setting in django:

DATABASES = {

  'default': {
        'ENGINE': 'django.db.backends.mysql',
        ...,
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
            'charset': 'utf8mb4'
         },
}

我总是收到这样的警告:

/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)

为什么我会收到上述警告?

任何评论都非常受欢迎。非常感谢。

1 个答案:

答案 0 :(得分:1)

尝试:

Loop through `progress` {
   if action_1 to action_3 {
     Task1.push
   }
   if action_4 to action_8 {
     Task2.push
   }
   if action_9 to action_11 {
     Task3.push
   }
}

您还可以看到warnings — Warning control