Browse Source

修复:在django2.2情况下连接mysql数据库异常的问题

root 3 years ago
parent
commit
6df27f4dd5
1 changed files with 20 additions and 0 deletions
  1. 20 0
      monitor/monitor_app/__init__.py

+ 20 - 0
monitor/monitor_app/__init__.py

@@ -0,0 +1,20 @@
+# coding:utf-8
+
+import os
+import sys
+import importlib
+from django.db.backends.mysql import operations
+
+for p in sys.path:
+    if p.endswith('/'):
+        p = p[:-1]
+    if p.endswith('/site-packages'):
+        file_path = os.path.join(p, 'django/db/backends/mysql/operations.py')
+        with open(file_path, 'r') as fr:
+            content = fr.read()
+        if content.find('query is not None') > -1:
+            content = content.replace('query is not None', 'False')
+            with open(file_path, 'w') as fw:
+                fw.write(content)
+            importlib.reload(operations)
+