feat: add execute-script route and handler for executing SQL scripts

This commit is contained in:
t8y2 committed 2026-05-05 03:22:26 +08:00
1 parent 41bceffc0e
commit 794c5375c7
3 files changed
+20 -1

No files matched your search

+17
View File
@@ -103,3 +103,20 @@ pub async fn cancel_query(
let cancelled = state.app.running_queries.cancel(&req.execution_id);
Json(serde_json::json!({ "cancelled": cancelled }))
}
pub async fn execute_script(
State(state): State<Arc<WebState>>,
Json(req): Json<ExecuteQueryRequest>,
) -> Result<Json<serde_json::Value>, AppError> {
let statements = dbx_core::sql::split_sql_statements(&req.sql);
let result = dbx_core::query::execute_statements(
&state.app,
&req.connection_id,
&req.database,
&statements,
)
.await
.map_err(AppError)?;
Ok(Json(serde_json::to_value(result).map_err(|e| AppError(e.to_string()))?))
}