25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
style: 恢复 hook 后 Rust 格式化
Illuminated2020feff43c45920
diff --git a/crates/dbx-cli/src/commands.rs b/crates/dbx-cli/src/commands.rsindex 9756891f7c..349ff0e2dd 100644--- a/crates/dbx-cli/src/commands.rs+++ b/crates/dbx-cli/src/commands.rs@@ -364,9 +364,7 @@ async fn safe_query(args: &[String]) -> CliEnvelope<serde_json::Value> {};let database = option_value(args, "--db").or(config.database.as_deref()).unwrap_or("");- match dbx_core::query::execute_sql_statement_with_row_limit(&state, &config.id, database, sql, None, None, limit)- .await- {+ match dbx_core::query::execute_sql_statement_with_row_limit(&state, &config.id, database, sql, None, None, limit).await {Ok(result) => ok(CliSource::Headless,serde_json::json!({@@ -595,19 +593,16 @@ mod tests {async fn create_large_sqlite_fixture(path: &std::path::Path, row_count: usize) {std::fs::File::create(path).unwrap();let pool = dbx_core::db::sqlite::connect_path(&path.display().to_string()).await.unwrap();- dbx_core::db::sqlite::execute_query(- &pool,- "CREATE TABLE numbers (id INTEGER PRIMARY KEY, value TEXT NOT NULL)",- )- .await- .unwrap();+ dbx_core::db::sqlite::execute_query(&pool, "CREATE TABLE numbers (id INTEGER PRIMARY KEY, value TEXT NOT NULL)")+ .await+ .unwrap();for id in 1..=row_count {dbx_core::db::sqlite::execute_query(&pool,&format!("INSERT INTO numbers (id, value) VALUES ({id}, 'value-{id}')"),)- .await- .unwrap();+ .await+ .unwrap();}pool.close().await;}diff --git a/crates/dbx-cli/src/main.rs b/crates/dbx-cli/src/main.rsindex 9a5a19356d..f34308a758 100644--- a/crates/dbx-cli/src/main.rs+++ b/crates/dbx-cli/src/main.rs@@ -4,7 +4,10 @@ mod runtime_client;#[tokio::main]async fn main() {if let Err(err) = commands::run(std::env::args().skip(1).collect()).await {- println!("{}", serde_json::to_string_pretty(&err).unwrap_or_else(|_| "{\"ok\":false}".to_string()));+ println!(+ "{}",+ serde_json::to_string_pretty(&err).unwrap_or_else(|_| "{\"ok\":false}".to_string())+ );std::process::exit(1);}}diff --git a/crates/dbx-cli/src/runtime_client.rs b/crates/dbx-cli/src/runtime_client.rsindex effa954a0a..81dda04c8e 100644--- a/crates/dbx-cli/src/runtime_client.rs+++ b/crates/dbx-cli/src/runtime_client.rs@@ -17,7 +17,8 @@ pub fn app_data_dir() -> PathBuf {return PathBuf::from(path);}- let home = std::env::var(if cfg!(windows) { "APPDATA" } else { "HOME" }).unwrap_or_else(|_| ".".to_string());+ let home = std::env::var(if cfg!(windows) { "APPDATA" } else { "HOME" })+ .unwrap_or_else(|_| ".".to_string());if cfg!(target_os = "macos") {PathBuf::from(home).join("Library/Application Support/com.dbx.app")@@ -42,30 +43,44 @@ pub async fn get_json(path: &str) -> Result<serde_json::Value, String> {let runtime = load_runtime().ok_or_else(|| "runtime unavailable".to_string())?;let url = runtime_url(&runtime, path, &[])?;- let response =- reqwest::Client::new().get(url).bearer_auth(runtime.token).send().await.map_err(|err| err.to_string())?;+ let response = reqwest::Client::new()+ .get(url)+ .bearer_auth(runtime.token)+ .send()+ .await+ .map_err(|err| err.to_string())?;let status = response.status();if !status.is_success() {return Err(format!("runtime request failed with status {status}"));}- response.json().await.map_err(|err| err.to_string())+ response+ .json()+ .await+ .map_err(|err| err.to_string())}pub async fn get_json_with_query(path: &str, query: &[(&str, String)]) -> Result<serde_json::Value, String> {let runtime = load_runtime().ok_or_else(|| "runtime unavailable".to_string())?;let url = runtime_url(&runtime, path, query)?;- let response =- reqwest::Client::new().get(url).bearer_auth(runtime.token).send().await.map_err(|err| err.to_string())?;+ let response = reqwest::Client::new()+ .get(url)+ .bearer_auth(runtime.token)+ .send()+ .await+ .map_err(|err| err.to_string())?;let status = response.status();if !status.is_success() {return Err(format!("runtime request failed with status {status}"));}- response.json().await.map_err(|err| err.to_string())+ response+ .json()+ .await+ .map_err(|err| err.to_string())}pub async fn post_json(path: &str, body: serde_json::Value) -> Result<serde_json::Value, String> {@@ -85,7 +100,10 @@ pub async fn post_json(path: &str, body: serde_json::Value) -> Result<serde_jsonreturn Err(format!("runtime request failed with status {status}"));}- response.json().await.map_err(|err| err.to_string())+ response+ .json()+ .await+ .map_err(|err| err.to_string())}fn runtime_url(runtime: &RuntimeDiscovery, path: &str, query: &[(&str, String)]) -> Result<reqwest::Url, String> {diff --git a/crates/dbx-core/src/cli.rs b/crates/dbx-core/src/cli.rsindex 6296e925a7..534c4e1f41 100644--- a/crates/dbx-core/src/cli.rs+++ b/crates/dbx-core/src/cli.rs@@ -116,12 +116,8 @@ wherelet source = source.ok_or_else(|| de::Error::missing_field("source"))?;match (ok, has_data, has_error) {- (true, true, false) => {- Ok(CliEnvelope::Success { ok, source, data: data.expect("data presence was checked") })- }- (false, false, true) => {- Ok(CliEnvelope::Failure { ok, source, error: error.expect("error presence was checked") })- }+ (true, true, false) => Ok(CliEnvelope::Success { ok, source, data: data.expect("data presence was checked") }),+ (false, false, true) => Ok(CliEnvelope::Failure { ok, source, error: error.expect("error presence was checked") }),(true, _, _) => Err(de::Error::custom("ok=true requires data without error")),(false, _, _) => Err(de::Error::custom("ok=false requires error without data")),}diff --git a/crates/dbx-core/src/db/sqlite.rs b/crates/dbx-core/src/db/sqlite.rsindex f2d668820c..a826513238 100644--- a/crates/dbx-core/src/db/sqlite.rs+++ b/crates/dbx-core/src/db/sqlite.rs@@ -165,11 +165,7 @@ pub async fn execute_query(pool: &SqlitePool, sql: &str) -> Result<QueryResult,execute_query_with_row_limit(pool, sql, crate::query::MAX_ROWS).await}-pub async fn execute_query_with_row_limit(- pool: &SqlitePool,- sql: &str,- row_limit: usize,-) -> Result<QueryResult, String> {+pub async fn execute_query_with_row_limit(pool: &SqlitePool, sql: &str, row_limit: usize) -> Result<QueryResult, String> {let start = Instant::now();let row_limit = row_limit.max(1);diff --git a/crates/dbx-core/src/storage.rs b/crates/dbx-core/src/storage.rsindex 4447929499..347caec01e 100644--- a/crates/dbx-core/src/storage.rs+++ b/crates/dbx-core/src/storage.rs@@ -144,11 +144,10 @@ async fn ensure_history_columns(pool: &SqlitePool) -> Result<(), String> {}async fn ensure_handoffs_sequence(pool: &SqlitePool) -> Result<(), String> {- let (seq_columns,): (i64,) =- sqlx::query_as("SELECT COUNT(*) FROM pragma_table_info('handoffs') WHERE name = 'seq'")- .fetch_one(pool)- .await- .map_err(|e| e.to_string())?;+ let (seq_columns,): (i64,) = sqlx::query_as("SELECT COUNT(*) FROM pragma_table_info('handoffs') WHERE name = 'seq'")+ .fetch_one(pool)+ .await+ .map_err(|e| e.to_string())?;if seq_columns > 0 {return Ok(());@@ -1058,8 +1057,10 @@ mod handoff_tests {async fn handoffs_table_has_stable_autoincrement_sequence() {let storage = open_temp_storage().await;- let columns: Vec<(String,)> =- sqlx::query_as("SELECT name FROM pragma_table_info('handoffs')").fetch_all(&storage.db).await.unwrap();+ let columns: Vec<(String,)> = sqlx::query_as("SELECT name FROM pragma_table_info('handoffs')")+ .fetch_all(&storage.db)+ .await+ .unwrap();assert!(columns.iter().any(|(name,)| name == "seq"));}diff --git a/src-tauri/src/commands/agent_runtime.rs b/src-tauri/src/commands/agent_runtime.rsindex a96ec9178c..8c1d093b2b 100644--- a/src-tauri/src/commands/agent_runtime.rs+++ b/src-tauri/src/commands/agent_runtime.rs@@ -306,7 +306,10 @@ async fn route_request(first_line: &str, body: &str, state: &AgentRuntimeState)if let Some(limit) = query_limit(first_line) {truncate_result_rows(&mut body, limit);}- return RuntimeResponse { status: "200 OK", body };+ return RuntimeResponse {+ status: "200 OK",+ body,+ };}if first_line.starts_with("POST /handoff ") {diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rsindex 69f61492d8..2040e4ca0b 100644--- a/src-tauri/src/commands/mod.rs+++ b/src-tauri/src/commands/mod.rs@@ -1,5 +1,5 @@-pub mod agent_runtime;pub mod ai;+pub mod agent_runtime;pub mod connection;#[allow(dead_code, unused_imports)]mod connection_secrets;