Enhance database management features by adding an API endpoint to drop all tables with double confirmation. Implement configuration file upload and download functionalities, including backup of the existing configuration. Update UI elements for improved user experience, including pagination controls and toast notifications. Adjust Docker and git ignore files to optimize build processes.

This commit is contained in:
2026-01-14 18:27:05 +08:00
parent 866fc1cb06
commit 5b50c9750f
19 changed files with 2424 additions and 166 deletions
+28
View File
@@ -245,6 +245,34 @@ class DatabaseManager:
conn.commit()
return True
def drop_all_tables(self) -> Dict[str, Any]:
"""删除所有表"""
with self.get_connection() as conn:
with conn.cursor() as cursor:
# 获取所有表名
cursor.execute("SHOW TABLES")
tables = [list(row.values())[0] for row in cursor.fetchall()]
if not tables:
return {"success": True, "dropped_count": 0, "tables": []}
# 删除所有表
dropped_tables = []
for table in tables:
try:
cursor.execute(f"DROP TABLE IF EXISTS `{table}`")
dropped_tables.append(table)
except Exception as e:
# 记录错误但继续删除其他表
pass
conn.commit()
return {
"success": True,
"dropped_count": len(dropped_tables),
"tables": dropped_tables
}
def execute_sql(self, sql: str) -> Tuple[bool, Any]:
"""执行自定义 SQL"""
with self.get_connection() as conn: