瀏覽代碼

버그 수정

잉여개발기 4 月之前
父節點
當前提交
20341329c0
共有 1 個文件被更改,包括 20 次插入8 次删除
  1. 20 8
      route/tool/func.py

+ 20 - 8
route/tool/func.py

@@ -299,14 +299,25 @@ class get_db_connect:
             while self.conn == None and try_cnt <= max_try:
                 try:
                     if self.init_mode:
-                        self.conn = pymysql.connect(
-                            host = self.db_set['db_mysql_host'],
-                            user = self.db_set['db_mysql_user'],
-                            password = self.db_set['db_mysql_pw'],
-                            charset = 'utf8mb4',
-                            port = int(self.db_set['db_mysql_port']),
-                            autocommit = True
-                        )
+                        try:
+                            self.conn = pymysql.connect(
+                                host = self.db_set['db_mysql_host'],
+                                user = self.db_set['db_mysql_user'],
+                                password = self.db_set['db_mysql_pw'],
+                                charset = 'utf8mb4',
+                                port = int(self.db_set['db_mysql_port']),
+                                autocommit = True,
+                                db = self.db_set['db_name']
+                            )
+                        except pymysql.err.OperationalError:
+                            self.conn = pymysql.connect(
+                                host = self.db_set['db_mysql_host'],
+                                user = self.db_set['db_mysql_user'],
+                                password = self.db_set['db_mysql_pw'],
+                                charset = 'utf8mb4',
+                                port = int(self.db_set['db_mysql_port']),
+                                autocommit = True
+                            )
                     else:
                         self.conn = pymysql.connect(
                             host = self.db_set['db_mysql_host'],
@@ -323,6 +334,7 @@ class get_db_connect:
                 finally:
                     if self.conn == None:
                         try_cnt += 1
+                        
                         time.sleep(1)
 
             if self.conn == None: