summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorhandingkang <[email protected]>2024-05-27 16:55:56 +0800
committerhandingkang <[email protected]>2024-05-27 16:55:56 +0800
commitc9690da79c589c1e9c533c04f974cc5fcb489486 (patch)
treebe9dffa30ea2577f5c92fa385b612f312d2d6fa0 /server
parent3c5f744bb43dc2cf16f8572bc3d4139ff085b0d4 (diff)
1. 优化数据库初始化逻辑
Diffstat (limited to 'server')
-rw-r--r--server/apps/util.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/server/apps/util.py b/server/apps/util.py
index 7e50f29..2205018 100644
--- a/server/apps/util.py
+++ b/server/apps/util.py
@@ -159,6 +159,15 @@ class DataHandler:
# 重复外键
if str(e).find("(1826"):
pass
+ # 完成初始化,重新以标明数据库的方式连接
+ try:
+ self.conn.close()
+ self.conn = pymysql.connect(cursorclass=DictCursor, host=MYSQL_HOST, user='root',
+ password=MYSQL_PAWD, port=MYSQL_PORT, database=MYSQL_DATADB)
+ except Exception as e:
+ error(str(e))
+ # 数据库连接失败,停止后续操作
+ sys.exit(1)
# 获取信息(代理、任务)
# data_type可选范围参照DataHandler.tabmapping的键