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

Method get_table_list

class/databaseModel/sqliteModel.py:175–204  ·  view source on GitHub ↗

@name 获取数据库表列表 @param args['path'] 数据库路径 @return list

(self,args)

Source from the content-addressed store, hash-verified

173 return nlist
174
175 def get_table_list(self,args):
176 """
177 @name 获取数据库表列表
178 @param args['path'] 数据库路径
179 @return list
180 """
181
182 path = args.path
183 if not os.path.exists(path):
184 return public.returnMsg(False,'数据库不存在.')
185
186 data = self.get_database_list()
187 if not path in data:
188 return public.returnMsg(False,'数据库不存在.')
189
190 db = self.get_db_info(path)
191 if not db:
192 return public.returnMsg(False,'数据库文件错误.')
193
194 result = []
195 sql = db['sql']
196 tables = sql.query('select `name` from sqlite_master where type="table"')
197 for table in tables:
198 info = {}
199 info['name'] = table[0]
200 if info['name'] in ['sqlite_sequence']:
201 continue
202 info['count'] = sql.table(info['name']).count() #获取表记录数
203 result.append(info) #添加到结果列表
204 return result
205
206 def get_table_info(self,args):
207 """

Callers

nothing calls this directly

Calls 8

get_database_listMethod · 0.95
get_db_infoMethod · 0.95
returnMsgMethod · 0.80
existsMethod · 0.45
queryMethod · 0.45
countMethod · 0.45
tableMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected