Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix: prevent implicit database creation on connection for SQLite (#1986)

hb7b0830789600
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index bb349a436c..a200a44f87 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -2561,6 +2561,13 @@ async function createDuckDbFilePath() {
const path = ensureDuckDbFileExtension(selected);
form.value.host = path;
+
+ try {
+ const { writeTextFile } = await import("@tauri-apps/plugin-fs");
+ await writeTextFile(path, "");
+ } catch (e) {
+ console.error("Failed to create DuckDB file:", e);
+ }
}
function ensureSqliteFileExtension(path: string): string {
@@ -2580,6 +2587,13 @@ async function createSqliteFilePath() {
const path = ensureSqliteFileExtension(selected);
form.value.host = path;
+
+ try {
+ const { writeTextFile } = await import("@tauri-apps/plugin-fs");
+ await writeTextFile(path, "");
+ } catch (e) {
+ console.error("Failed to create SQLite file:", e);
+ }
}
async function browseJdbcDriverPaths() {
diff --git a/crates/dbx-core/src/connection.rs b/crates/dbx-core/src/connection.rs
index 42c0ee0656..a4ac772cff 100644
--- a/crates/dbx-core/src/connection.rs
+++ b/crates/dbx-core/src/connection.rs
@@ -712,11 +712,7 @@ impl AppState {
})
.collect();
PoolKind::Sqlite(
- db::sqlite::connect_path_create_if_missing_with_extensions(
- &expand_tilde(&db_config.host),
- extensions,
- )
- .await?,
+ db::sqlite::connect_path_with_extensions(&expand_tilde(&db_config.host), extensions).await?,
)
}
DatabaseType::Rqlite => {
diff --git a/crates/dbx-core/src/db/duckdb_driver.rs b/crates/dbx-core/src/db/duckdb_driver.rs
index 69db54d132..8ef56bea71 100644
--- a/crates/dbx-core/src/db/duckdb_driver.rs
+++ b/crates/dbx-core/src/db/duckdb_driver.rs
@@ -39,11 +39,7 @@ fn validate_duckdb_path(path: &str) -> Result<(), String> {
return Err(format!("Database file path is a directory, not a file: {}", path));
}
if !path_obj.exists() {
- if let Some(parent) = path_obj.parent() {
- if !parent.as_os_str().is_empty() && !parent.exists() {
- return Err(format!("Parent directory does not exist: {}", parent.display()));
- }
- }
+ return Err(format!("Database file does not exist: {}", path));
}
Ok(())
}
diff --git a/src-tauri/src/commands/connection.rs b/src-tauri/src/commands/connection.rs
index 12fd7b25be..d662e9128a 100644
--- a/src-tauri/src/commands/connection.rs
+++ b/src-tauri/src/commands/connection.rs
@@ -605,12 +605,7 @@ pub async fn test_connection(state: State<'_, Arc<AppState>>, config: Connection
extension
})
.collect();
- match db::sqlite::connect_path_create_if_missing_with_extensions(
- &expand_tilde(&config.host),
- extensions,
- )
- .await
- {
+ match db::sqlite::connect_path_with_extensions(&expand_tilde(&config.host), extensions).await {
Ok(_) => Ok("Connection successful".to_string()),
Err(e) => Err(e),
}
@@ -875,8 +870,7 @@ pub async fn connect_db(state: State<'_, Arc<AppState>>, config: ConnectionConfi
})
.collect();
PoolKind::Sqlite(
- db::sqlite::connect_path_create_if_missing_with_extensions(&expand_tilde(&db_config.host), extensions)
- .await?,
+ db::sqlite::connect_path_with_extensions(&expand_tilde(&db_config.host), extensions).await?,
)
}
DatabaseType::Redis => {