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

Method get_database_password

script/btcli.py:473–501  ·  view source on GitHub ↗

获取数据库密码 Args: db_id: 数据库ID db_name: 数据库名称

(self, db_id: int = None, db_name: str = None)

Source from the content-addressed store, hash-verified

471 print(Colors.error(f"删除数据库失败: {str(e)}"))
472
473 def get_database_password(self, db_id: int = None, db_name: str = None):
474 """
475 获取数据库密码
476
477 Args:
478 db_id: 数据库ID
479 db_name: 数据库名称
480 """
481 try:
482 if db_name and not db_id:
483 db_info = public.M('databases').where('name=?', (db_name,)).find()
484 if not db_info:
485 print(Colors.error(f"数据库不存在: {db_name}"))
486 return
487 db_id = db_info['id']
488
489 if not db_id:
490 print(Colors.error("请提供数据库ID或数据库名称"))
491 return
492
493 db_info = public.M('databases').where('id=?', (db_id,)).find()
494 if not db_info:
495 print(Colors.error(f"数据库不存在: {db_id}"))
496 return
497 print("")
498 print(Colors.success(f"✓ 数据库密码获取成功"))
499 print(f" 密码: {db_info['password']}")
500 except Exception as e:
501 print(Colors.error(f"获取数据库密码失败: {str(e)}"))
502
503 # ============ 预留功能接口 ============
504

Callers 1

database_menuMethod · 0.80

Calls 5

findMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
errorMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected