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

Method get_table_info

class/databaseModel/sqliteModel.py:206–268  ·  view source on GitHub ↗

@name 获取表信息 @param args['path'] 数据库路径 @param args['table'] 表名 @return list

(self,args)

Source from the content-addressed store, hash-verified

204 return result
205
206 def get_table_info(self,args):
207 """
208 @name 获取表信息
209 @param args['path'] 数据库路径
210 @param args['table'] 表名
211 @return list
212 """
213
214 path = args.path
215 table = args.table
216 if not os.path.exists(path):
217 return public.returnMsg(False,'数据库不存在.')
218
219 data = self.get_database_list()
220 if not path in data:
221 return public.returnMsg(False,'数据库不存在.')
222
223 db = self.get_db_info(path)
224 if not db:
225 return public.returnMsg(False,'数据库文件错误.')
226
227 sql = db['sql'].table(table) #获取表对象
228 order = ""
229 if hasattr(args,'order'):
230 order = args.order
231
232 where = '1=1'
233 limit = 10
234 if hasattr(args,'limit'):
235 limit = int(args.limit)
236
237 if hasattr(args,'search') and args.search:
238
239 w_list = []
240 slist = sql.query('PRAGMA table_info({})'.format(table))
241 for val in slist:
242 w_list.append("`{}` like '%{}%'".format(val[1],args.search))
243 where = ' or '.join(w_list)
244
245 import page
246 #实例化分页类
247 page = page.Page()
248
249 info = {}
250 info['count'] = sql.where(where,()).count()
251 info['row'] = limit
252 info['uri'] = args
253 info['p'] = 1
254 if hasattr(args,'p'):
255 info['p'] = int(args['p'])
256
257 info['return_js'] = ''
258 if hasattr(args,'tojs'):
259 info['return_js'] = args.tojs
260
261 data['where'] = where
262 data['page'] = page.GetPage(info,'1,2,3,4,5,8') #获取分页数据
263 data['data'] = sql.where(where,()).order(order).limit(str(page.SHIFT)+','+str(page.ROW)).select() #取出数据

Callers

nothing calls this directly

Calls 15

get_database_listMethod · 0.95
get_db_infoMethod · 0.95
GetPageMethod · 0.95
returnMsgMethod · 0.80
existsMethod · 0.45
tableMethod · 0.45
queryMethod · 0.45
formatMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45
countMethod · 0.45
whereMethod · 0.45

Tested by

no test coverage detected