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

Method list_databases

script/btcli.py:366–394  ·  view source on GitHub ↗

显示数据库列表

(self)

Source from the content-addressed store, hash-verified

364 return False
365
366 def list_databases(self):
367 """显示数据库列表"""
368 try:
369 result = public.M('databases').field('id,name,username,password,accept,ps,addtime').select()
370
371 if not result:
372 print(Colors.warning("暂无数据库"))
373 return
374
375 headers = ["ID", "数据库名", "用户名", "密码", "访问权限", "备注", "创建时间"]
376 rows = []
377
378 for db in result:
379 # 密码打码显示
380 password_masked = '*' * 8 if db.get('password') else '-'
381 rows.append([
382 db['id'],
383 db['name'],
384 db['username'],
385 password_masked,
386 db.get('accept', 'localhost'),
387 db.get('ps', '-')[:15],
388 db['addtime']
389 ])
390
391 TablePrinter.print_table(headers, rows, f"数据库列表 (共 {len(rows)} 个)")
392
393 except Exception as e:
394 print(Colors.error(f"获取数据库列表失败: {str(e)}"))
395
396 def add_database(self, db_name: str, password: str = None, **kwargs):
397 """

Callers 2

mainFunction · 0.95
database_menuMethod · 0.45

Calls 8

print_tableMethod · 0.80
selectMethod · 0.45
fieldMethod · 0.45
MMethod · 0.45
warningMethod · 0.45
getMethod · 0.45
appendMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected