From 84b7d1123e51ad589bc8c3e8cf1d5ebefa582c51 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 14 Dec 2024 04:49:21 +0800 Subject: [PATCH] Update sql_mysql.py --- plugins/data_query/sql_mysql.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/data_query/sql_mysql.py b/plugins/data_query/sql_mysql.py index 6179f00e3..38205e6ab 100755 --- a/plugins/data_query/sql_mysql.py +++ b/plugins/data_query/sql_mysql.py @@ -23,6 +23,8 @@ def singleton(cls): @singleton class nosqlMySQL(): + __sid = None + __DB_PASS = None __DB_USER = None __DB_PORT = 3306 @@ -40,6 +42,15 @@ class nosqlMySQL(): self.__config = self.get_options(sid=sid) def conn(self): + + if self.__sid is not: + return False + + if self.__sid is not None: + mycnf_path = "{}/{}/etc/my.cnf".format(mw.getServerDir(),sid) + if not os.path.exists(mycnf_path): + return False + self.__DB_PORT = int(self.__config['port']) self.__DB_USER = self.__config['username'] self.__DB_PASS = self.__config['password'] @@ -74,6 +85,8 @@ class nosqlMySQL(): if sid in ['mysql', 'mysql-apt', 'mysql-yum']: my_cnf_path = "{}/{}/etc/my.cnf".format(mw.getServerDir(),sid) + if not os.path.exists(my_cnf_path): + return False mydb_content = mw.readFile(my_cnf_path) if not mydb_content: return False