From eb4c1bd953222d213b094bec7ca568d77a2fac97 Mon Sep 17 00:00:00 2001 From: Eukanj827 Date: Mon, 15 Aug 2022 09:58:17 +0800 Subject: [PATCH] Update driver_execute.py --- .../components/index_advisor/dao/driver_execute.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gausskernel/dbmind/tools/components/index_advisor/dao/driver_execute.py b/src/gausskernel/dbmind/tools/components/index_advisor/dao/driver_execute.py index 38951401e..7f69748a6 100644 --- a/src/gausskernel/dbmind/tools/components/index_advisor/dao/driver_execute.py +++ b/src/gausskernel/dbmind/tools/components/index_advisor/dao/driver_execute.py @@ -18,19 +18,19 @@ import psycopg2 from .execute_factory import ExecuteFactory from .execute_factory import IndexInfo -#class name: -#description: -#methods: -#note: +#class name: DriverExecute (Inherits from the parent class ExecuteFactory) +#description: The SQL statement performs the operations associated with the call #date: 2022/8/10 #contact: 1865997821 class DriverExecute(ExecuteFactory): def __init__(self, *arg): + #Call the arguments of the parent class __init__ method super(DriverExecute, self).__init__(*arg) self.conn = None self.cur = None + #Connecting to the database def init_conn_handle(self): self.conn = psycopg2.connect(dbname=self.dbname, user=self.user, @@ -39,6 +39,7 @@ class DriverExecute(ExecuteFactory): port=self.port) self.cur = self.conn.cursor() +#If an error occurs after the SQL statement is executed, the error information is reported to the user def execute(self, sql): try: self.cur.execute(sql) @@ -47,11 +48,13 @@ class DriverExecute(ExecuteFactory): except Exception: self.conn.commit() +#Disconnecting from the database def close_conn(self): if self.conn and self.cur: self.cur.close() self.conn.close() +#Check whether multiple nodes exist def is_multi_node(self): self.init_conn_handle() try: