MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / query

Method query

class/databaseModel/pgsqlModel.py:137–156  ·  view source on GitHub ↗
(self, sql)

Source from the content-addressed store, hash-verified

135 return ex
136
137 def query(self, sql):
138
139 # 执行SQL语句返回数据集
140 if self.__DB_CONN is None:
141 status, err_msg = self.connect()
142 if status is False:
143 return err_msg
144 if self.__DB_CONN.closed or self.__DB_CUR.closed: # 判断是否关闭,关闭重新连接
145 status, err_msg = self.connect()
146 if status is False:
147 return err_msg
148 try:
149 self.__DB_CUR.execute(sql)
150 result = self.__DB_CUR.fetchall()
151
152 data = list(map(list, result))
153 self.__Close()
154 return data
155 except Exception as ex:
156 return ex
157
158 def use_database(self, database_name):
159 """

Callers 15

check_field_existsMethod · 0.45
InputSqlMethod · 0.45
SyncGetDatabasesMethod · 0.45
CheckDatabaseStatusMethod · 0.45
get_table_listMethod · 0.45
get_table_infoMethod · 0.45
create_tableMethod · 0.45
query_sqlMethod · 0.45
get_keys_bytableMethod · 0.45

Calls 4

connectMethod · 0.95
__CloseMethod · 0.95
mapFunction · 0.85
executeMethod · 0.45

Tested by

no test coverage detected