@name 获取数据库表列表 @param args['path'] 数据库路径 @return list
(self,args)
| 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 | """ |
nothing calls this directly
no test coverage detected