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

Method delete_database

script/btcli.py:431–471  ·  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

429 print(Colors.error(f"添加数据库失败: {str(e)}"))
430
431 def delete_database(self, db_id: int = None, db_name: str = None):
432 """
433 删除数据库
434
435 Args:
436 db_id: 数据库ID
437 db_name: 数据库名称
438 """
439 try:
440 # 如果提供的是数据库名称,查询ID
441 if db_name and not db_id:
442 db_info = public.M('databases').where('name=?', (db_name,)).find()
443 if not db_info:
444 print(Colors.error(f"数据库不存在: {db_name}"))
445 return
446 db_id = db_info['id']
447
448 if not db_id:
449 print(Colors.error("请提供数据库ID或数据库名称"))
450 return
451
452 # 确认删除
453 confirm = input(Colors.warning(f"确认删除数据库 (ID: {db_id})? [y/N]: "))
454 if confirm.lower() != 'y':
455 print("已取消")
456 return
457
458 # 构造参数
459 args = public.dict_obj()
460 args.id = db_id
461 args.name = db_name or db_id
462
463 result = self.db_obj.DeleteDatabase(args)
464
465 if result.get('status'):
466 print(Colors.success(f"✓ 数据库删除成功"))
467 else:
468 print(Colors.error(f"✗ 数据库删除失败: {result.get('msg', '未知错误')}"))
469
470 except Exception as e:
471 print(Colors.error(f"删除数据库失败: {str(e)}"))
472
473 def get_database_password(self, db_id: int = None, db_name: str = None):
474 """

Callers 2

mainFunction · 0.95
database_menuMethod · 0.45

Calls 8

findMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
errorMethod · 0.45
warningMethod · 0.45
DeleteDatabaseMethod · 0.45
getMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected