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。

ci: install x86_64 unixodbc for cross-compilation on ARM macOS

t8y263b74583472b
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 8912273514..797a086e2e 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -61,7 +61,17 @@ jobs:
- name: Install system dependencies (macOS)
if: startsWith(matrix.platform, 'macos')
- run: brew install unixodbc
+ run: |
+ if [ "${{ matrix.target }}" = "x86_64-apple-darwin" ]; then
+ arch -x86_64 /bin/bash -c '
+ eval "$(/usr/local/bin/brew shellenv 2>/dev/null || /usr/local/Homebrew/bin/brew shellenv 2>/dev/null)"
+ brew install unixodbc
+ '
+ echo "LIBRARY_PATH=/usr/local/lib" >> "$GITHUB_ENV"
+ echo "PKG_CONFIG_PATH=/usr/local/lib/pkgconfig" >> "$GITHUB_ENV"
+ else
+ brew install unixodbc
+ fi
- name: Install Apple certificate (macOS)
if: startsWith(matrix.platform, 'macos')
diff --git a/crates/dbx-core/src/db/mysql.rs b/crates/dbx-core/src/db/mysql.rs
index 22215ec84f..9012a93d33 100644
--- a/crates/dbx-core/src/db/mysql.rs
+++ b/crates/dbx-core/src/db/mysql.rs
@@ -185,7 +185,7 @@ pub async fn list_databases(pool: &MySqlPool) -> Result<Vec<DatabaseInfo>, Strin
pub async fn list_tables(pool: &MySqlPool, database: &str) -> Result<Vec<TableInfo>, String> {
let sql = format!(
- "SELECT TABLE_NAME, TABLE_TYPE FROM information_schema.TABLES WHERE TABLE_SCHEMA = {} ORDER BY TABLE_NAME",
+ "SELECT TABLE_NAME, TABLE_TYPE, TABLE_COMMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = {} ORDER BY TABLE_NAME",
quote_value(database),
);
let rows: Vec<MySqlRow> = sqlx::raw_sql(&sql).fetch_all(pool).await.map_err(|e| e.to_string())?;
@@ -195,6 +195,7 @@ pub async fn list_tables(pool: &MySqlPool, database: &str) -> Result<Vec<TableIn
.map(|row| TableInfo {
name: get_str_by_name(row, "TABLE_NAME"),
table_type: get_str_by_name(row, "TABLE_TYPE"),
+ comment: row.try_get::<String, _>("TABLE_COMMENT").ok().filter(|s| !s.is_empty()),
})
.collect())
}
diff --git a/crates/dbx-core/src/db/postgres.rs b/crates/dbx-core/src/db/postgres.rs
index a7333c2a7e..9f1bc8801e 100644
--- a/crates/dbx-core/src/db/postgres.rs
+++ b/crates/dbx-core/src/db/postgres.rs
@@ -162,8 +162,11 @@ pub async fn list_databases(pool: &PgPool) -> Result<Vec<DatabaseInfo>, String>
pub async fn list_tables(pool: &PgPool, schema: &str) -> Result<Vec<TableInfo>, String> {
let rows: Vec<PgRow> = sqlx::query(
- "SELECT table_name, table_type FROM information_schema.tables \
- WHERE table_schema = $1 ORDER BY table_name",
+ "SELECT t.table_name, t.table_type, obj_description(c.oid) AS table_comment \
+ FROM information_schema.tables t \
+ LEFT JOIN pg_catalog.pg_class c ON c.relname = t.table_name \
+ LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace AND n.nspname = t.table_schema \
+ WHERE t.table_schema = $1 ORDER BY t.table_name",
)
.bind(schema)
.fetch_all(pool)
@@ -175,6 +178,7 @@ pub async fn list_tables(pool: &PgPool, schema: &str) -> Result<Vec<TableInfo>,
.map(|row| TableInfo {
name: row.get::<String, _>("table_name"),
table_type: row.get::<String, _>("table_type"),
+ comment: row.get::<Option<String>, _>("table_comment").filter(|s| !s.is_empty()),
})
.collect())
}
diff --git a/crates/dbx-core/src/types.rs b/crates/dbx-core/src/types.rs
index aedd248fb1..8e271cae23 100644
--- a/crates/dbx-core/src/types.rs
+++ b/crates/dbx-core/src/types.rs
@@ -9,6 +9,7 @@ pub struct DatabaseInfo {
pub struct TableInfo {
pub name: String,
pub table_type: String, // "TABLE" or "VIEW"
+ pub comment: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]