From 4588bd89963addb6a7d6715f1ce299c6279de86f Mon Sep 17 00:00:00 2001
From: pycook <pycook@126.com>
Date: Fri, 23 Feb 2024 11:05:11 +0800
Subject: [PATCH] fix(api): db-setup commands (#399)

fix(api): db-setup commands
---
 cmdb-api/api/commands/common.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmdb-api/api/commands/common.py b/cmdb-api/api/commands/common.py
index 011aa30..c7ccf25 100644
--- a/cmdb-api/api/commands/common.py
+++ b/cmdb-api/api/commands/common.py
@@ -89,9 +89,12 @@ def db_setup():
     """
     db.create_all()
 
-    db.session.execute("set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,"
-                       "ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'")
-    db.session.commit()
+    try:
+        db.session.execute("set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,"
+                           "ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'")
+        db.session.commit()
+    except:
+        pass
 
     try:
         db.session.execute("set global tidb_enable_noop_functions='ON'")