dbx-database-client

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

DBX Database Client

DBX数据库客户端

Skill by ara.so — Daily 2026 Skills collection.
DBX is an open-source, lightweight (~15 MB), cross-platform database management GUI built with Tauri 2 (Rust backend) + Vue 3 frontend. It supports MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, ClickHouse, SQL Server, MariaDB, TiDB, and more — with no bundled Chromium.
来自ara.so的技能——Daily 2026技能合集。
DBX是一款开源、轻量级(约15 MB)的跨平台数据库管理GUI工具,基于Tauri 2(Rust后端)+ Vue 3前端构建。它支持MySQL、PostgreSQL、SQLite、Redis、MongoDB、DuckDB、ClickHouse、SQL Server、MariaDB、TiDB等多种数据库,且未捆绑Chromium。

Installation

安装

Download Pre-built Binary

下载预构建二进制文件

Download the latest installer from Releases.
macOS (unsigned app workaround):
bash
xattr -cr /Applications/dbx.app
Or: System Settings → Privacy & Security → Open Anyway.
Releases下载最新安装程序。
macOS(未签名应用解决方法):
bash
xattr -cr /Applications/dbx.app
或者:系统设置 → 隐私与安全性 → 仍要打开。

Build from Source

从源码构建

Prerequisites:
  • Node.js >= 18
  • pnpm
  • Rust >= 1.77
bash
git clone https://github.com/t8y2/dbx.git
cd dbx
pnpm install
pnpm tauri dev        # Development mode
pnpm tauri build      # Production build → src-tauri/target/release/bundle/
前置要求:
  • Node.js >= 18
  • pnpm
  • Rust >= 1.77
bash
git clone https://github.com/t8y2/dbx.git
cd dbx
pnpm install
pnpm tauri dev        # 开发模式
pnpm tauri build      # 生产构建 → src-tauri/target/release/bundle/

Tech Stack

技术栈

LayerTechnology
FrameworkTauri 2
FrontendVue 3 + TypeScript
UIshadcn-vue + Tailwind CSS
EditorCodeMirror 6
BackendRust + sqlx / tiberius / redis-rs / mongodb
层级技术
框架Tauri 2
前端Vue 3 + TypeScript
UIshadcn-vue + Tailwind CSS
编辑器CodeMirror 6
后端Rust + sqlx / tiberius / redis-rs / mongodb

Project Structure

项目结构

dbx/
├── src/                    # Vue 3 frontend
│   ├── components/         # UI components
│   │   ├── ConnectionForm.vue
│   │   ├── QueryEditor.vue
│   │   ├── DataGrid.vue
│   │   └── SchemaBrowser.vue
│   ├── stores/             # Pinia stores
│   ├── composables/        # Vue composables
│   └── locales/            # i18n (en, zh-CN)
├── src-tauri/              # Rust backend
│   ├── src/
│   │   ├── commands/       # Tauri commands (IPC)
│   │   ├── db/             # Database drivers
│   │   │   ├── mysql.rs
│   │   │   ├── postgres.rs
│   │   │   ├── sqlite.rs
│   │   │   ├── redis.rs
│   │   │   ├── mongodb.rs
│   │   │   ├── duckdb.rs
│   │   │   └── clickhouse.rs
│   │   └── main.rs
│   ├── Cargo.toml
│   └── tauri.conf.json
└── package.json
dbx/
├── src/                    # Vue 3前端
│   ├── components/         # UI组件
│   │   ├── ConnectionForm.vue
│   │   ├── QueryEditor.vue
│   │   ├── DataGrid.vue
│   │   └── SchemaBrowser.vue
│   ├── stores/             # Pinia状态管理
│   ├── composables/        # Vue组合式函数
│   └── locales/            # 国际化(en, zh-CN)
├── src-tauri/              # Rust后端
│   ├── src/
│   │   ├── commands/       # Tauri命令(IPC)
│   │   ├── db/             # 数据库驱动
│   │   │   ├── mysql.rs
│   │   │   ├── postgres.rs
│   │   │   ├── sqlite.rs
│   │   │   ├── redis.rs
│   │   │   ├── mongodb.rs
│   │   │   ├── duckdb.rs
│   │   │   └── clickhouse.rs
│   │   └── main.rs
│   ├── Cargo.toml
│   └── tauri.conf.json
└── package.json

Adding a Database Connection

添加数据库连接

DBX stores connections locally. In the UI, click + New Connection and fill in:
FieldDescription
TypeMySQL / PostgreSQL / SQLite / Redis / MongoDB / DuckDB / ClickHouse / SQL Server
HostDatabase host (e.g.,
localhost
)
PortDefault port auto-fills by type
DatabaseDatabase/schema name
UsernameDB user
PasswordDB password (stored encrypted locally)
SSH TunnelOptional: host, port, user, key/password
DBX在本地存储连接信息。在UI中,点击**+ 新建连接**并填写以下内容:
字段描述
类型MySQL / PostgreSQL / SQLite / Redis / MongoDB / DuckDB / ClickHouse / SQL Server
主机数据库主机(例如:
localhost
端口根据类型自动填充默认端口
数据库数据库/模式名称
用户名数据库用户
密码数据库密码(本地加密存储)
SSH隧道可选:主机、端口、用户、密钥/密码

Connection String Examples

连接字符串示例

undefined
undefined

MySQL / MariaDB / TiDB

MySQL / MariaDB / TiDB

mysql://user:password@localhost:3306/mydb
mysql://user:password@localhost:3306/mydb

PostgreSQL / openGauss / GaussDB

PostgreSQL / openGauss / GaussDB

postgresql://user:password@localhost:5432/mydb
postgresql://user:password@localhost:5432/mydb

SQLite (file path or drag & drop .db file)

SQLite(文件路径或拖拽.db文件)

/path/to/database.db
/path/to/database.db

Redis

Redis

redis://localhost:6379 redis://:password@localhost:6379/0
redis://localhost:6379 redis://:password@localhost:6379/0

MongoDB

MongoDB

mongodb://user:password@localhost:27017/mydb mongodb+srv://user:password@cluster.mongodb.net/mydb
mongodb://user:password@localhost:27017/mydb mongodb+srv://user:password@cluster.mongodb.net/mydb

ClickHouse

ClickHouse

clickhouse://user:password@localhost:8123/default
clickhouse://user:password@localhost:8123/default

DuckDB

DuckDB

/path/to/database.duckdb
undefined
/path/to/database.duckdb
undefined

Query Editor

查询编辑器

Keyboard Shortcuts

键盘快捷键

ShortcutAction
Cmd/Ctrl + Enter
Execute query
Cmd/Ctrl + scroll
Zoom editor font size
Cmd/Ctrl + /
Toggle comment
Cmd/Ctrl + Z
Undo
快捷键操作
Cmd/Ctrl + Enter
执行查询
Cmd/Ctrl + 滚动
缩放编辑器字体大小
Cmd/Ctrl + /
切换注释
Cmd/Ctrl + Z
撤销

Features

功能特性

  • CodeMirror 6 with SQL syntax highlighting
  • Multi-statement execution
  • Safety dialogs for destructive operations (
    DROP
    ,
    DELETE
    ,
    TRUNCATE
    ,
    ALTER
    )
  • Query history with search, restore, one-click copy
  • 带有SQL语法高亮的CodeMirror 6
  • 多语句执行
  • 破坏性操作(
    DROP
    ,
    DELETE
    ,
    TRUNCATE
    ,
    ALTER
    )的安全提示对话框
  • 带搜索、恢复、一键复制的查询历史记录

AI SQL Assistant Configuration

AI SQL助手配置

DBX supports Claude and OpenAI for natural language → SQL, explain, optimize, and fix errors.
Configure via Settings → AI Assistant:
typescript
// Environment variables used by the app (set in your shell or .env)
OPENAI_API_KEY=sk-...        // OpenAI key
ANTHROPIC_API_KEY=sk-ant-... // Claude/Anthropic key
Capabilities:
  • Generate: "Show me all users who signed up last month"
  • Explain: Highlights query → "Explain this SQL"
  • Optimize: "Why is this query slow?"
  • Fix: Paste error → "Fix this query"
DBX支持Claude和OpenAI,可实现自然语言转SQL、查询解释、优化及错误修复。
通过设置 → AI助手进行配置:
typescript
// 应用使用的环境变量(在shell或.env中设置)
OPENAI_API_KEY=sk-...        // OpenAI密钥
ANTHROPIC_API_KEY=sk-ant-... // Claude/Anthropic密钥
功能:
  • 生成:“显示所有上个月注册的用户”
  • 解释:高亮查询 → “解释这段SQL”
  • 优化:“为什么这个查询很慢?”
  • 修复:粘贴错误信息 → “修复这个查询”

Data Grid Features

数据网格功能

  • Virtual scrolling for large datasets
  • Inline cell editing
  • Column resize by drag
  • Row numbers and zebra stripes
  • Sort by column header click
  • Search/filter rows
  • Pagination controls
Export options: CSV, JSON, Markdown (toolbar button or right-click)
  • 大数据集虚拟滚动
  • 单元格内联编辑
  • 拖拽调整列宽
  • 行号和斑马纹
  • 点击列标题排序
  • 行搜索/过滤
  • 分页控制
导出选项: CSV、JSON、Markdown(工具栏按钮或右键菜单)

Schema Browser

模式浏览器

Left sidebar tree structure:
Connection
└── Database/Schema
    ├── Tables
    │   └── table_name
    │       ├── Columns (name, type, nullable)
    │       ├── Indexes
    │       ├── Foreign Keys
    │       └── Triggers
    ├── Views
    └── Procedures
Double-click a table → opens data grid with
SELECT * FROM table LIMIT 1000
.
左侧侧边栏树形结构:
连接
└── 数据库/模式
    ├── 表
    │   └── table_name
    │       ├── 列(名称、类型、是否可为空)
    │       ├── 索引
    │       ├── 外键
    │       └── 触发器
    ├── 视图
    └── 存储过程
双击表 → 打开数据网格并执行
SELECT * FROM table LIMIT 1000

Redis Browser

Redis浏览器

  • Key pattern search (e.g.,
    user:*
    ,
    session:*
    )
  • Value viewer for all Redis types:
    • String: raw value display
    • Hash: field/value table
    • List: indexed list
    • Set: member list
    • ZSet: score/member table
  • TTL display and key deletion
  • 键模式搜索(例如:
    user:*
    ,
    session:*
  • 支持所有Redis类型的值查看器:
    • 字符串:原始值显示
    • 哈希:字段/值表格
    • 列表:索引列表
    • 集合:成员列表
    • 有序集合:分数/成员表格
  • TTL显示和键删除

MongoDB Browser

MongoDB浏览器

  • Database → Collection tree
  • Document list with pagination
  • CRUD: Create, Read, Update, Delete documents
  • JSON document editor
  • 数据库 → 集合树形结构
  • 带分页的文档列表
  • CRUD:创建、读取、更新、删除文档
  • JSON文档编辑器

SSH Tunnel

SSH隧道

Configure SSH tunnel in the connection form:
SSH Host: bastion.example.com
SSH Port: 22
SSH User: ec2-user
Auth:     Key (paste private key) OR Password
The tunnel proxies the DB connection through the SSH host — useful for databases not exposed to the internet.
在连接表单中配置SSH隧道:
SSH主机: bastion.example.com
SSH端口: 22
SSH用户: ec2-user
认证:     密钥(粘贴私钥)或密码
隧道通过SSH主机代理数据库连接——适用于未暴露在公网的数据库。

Drag & Drop Files

文件拖拽

Drag
.db
,
.sqlite
, or
.duckdb
files directly onto the DBX window to open them instantly without configuring a connection.
直接将
.db
.sqlite
.duckdb
文件拖拽到DBX窗口,无需配置连接即可立即打开。

Frontend Development Patterns

前端开发模式

Invoking Rust Commands from Vue

从Vue调用Rust命令

typescript
// src/composables/useDatabase.ts
import { invoke } from '@tauri-apps/api/core'

interface QueryResult {
  columns: string[]
  rows: Record<string, unknown>[]
  rowsAffected: number
  executionTime: number
}

export function useDatabase() {
  const executeQuery = async (connectionId: string, sql: string): Promise<QueryResult> => {
    return await invoke('execute_query', {
      connectionId,
      sql,
    })
  }

  const testConnection = async (config: ConnectionConfig): Promise<boolean> => {
    return await invoke('test_connection', { config })
  }

  return { executeQuery, testConnection }
}
typescript
// src/composables/useDatabase.ts
import { invoke } from '@tauri-apps/api/core'

interface QueryResult {
  columns: string[]
  rows: Record<string, unknown>[]
  rowsAffected: number
  executionTime: number
}

export function useDatabase() {
  const executeQuery = async (connectionId: string, sql: string): Promise<QueryResult> => {
    return await invoke('execute_query', {
      connectionId,
      sql,
    })
  }

  const testConnection = async (config: ConnectionConfig): Promise<boolean> => {
    return await invoke('test_connection', { config })
  }

  return { executeQuery, testConnection }
}

Adding a New Rust Command

添加新的Rust命令

rust
// src-tauri/src/commands/query.rs
use tauri::State;
use crate::db::ConnectionPool;

#[tauri::command]
pub async fn execute_query(
    connection_id: String,
    sql: String,
    pool: State<'_, ConnectionPool>,
) -> Result<QueryResult, String> {
    let conn = pool.get(&connection_id)
        .ok_or("Connection not found")?;
    
    conn.query(&sql).await.map_err(|e| e.to_string())
}
rust
// src-tauri/src/main.rs
fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![
            execute_query,
            test_connection,
            // ... other commands
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
rust
// src-tauri/src/commands/query.rs
use tauri::State;
use crate::db::ConnectionPool;

#[tauri::command]
pub async fn execute_query(
    connection_id: String,
    sql: String,
    pool: State<'_, ConnectionPool>,
) -> Result<QueryResult, String> {
    let conn = pool.get(&connection_id)
        .ok_or("Connection not found")?;
    
    conn.query(&sql).await.map_err(|e| e.to_string())
}
rust
// src-tauri/src/main.rs
fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![
            execute_query,
            test_connection,
            // ... 其他命令
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Vue Component Example: Custom Query Panel

Vue组件示例:自定义查询面板

vue
<!-- src/components/QueryPanel.vue -->
<script setup lang="ts">
import { ref } from 'vue'
import { invoke } from '@tauri-apps/api/core'
import { useConnectionStore } from '@/stores/connection'

const store = useConnectionStore()
const sql = ref('')
const results = ref(null)
const error = ref('')
const loading = ref(false)

async function runQuery() {
  if (!sql.value.trim()) return
  loading.value = true
  error.value = ''
  try {
    results.value = await invoke('execute_query', {
      connectionId: store.activeConnectionId,
      sql: sql.value,
    })
  } catch (e) {
    error.value = String(e)
  } finally {
    loading.value = false
  }
}
</script>

<template>
  <div class="flex flex-col gap-2 h-full">
    <textarea
      v-model="sql"
      class="font-mono text-sm border rounded p-2 h-40 resize-none"
      placeholder="SELECT * FROM users LIMIT 10"
      @keydown.meta.enter="runQuery"
      @keydown.ctrl.enter="runQuery"
    />
    <button
      :disabled="loading"
      class="px-4 py-2 bg-primary text-white rounded"
      @click="runQuery"
    >
      {{ loading ? 'Running...' : 'Run (Cmd+Enter)' }}
    </button>
    <div v-if="error" class="text-red-500 text-sm">{{ error }}</div>
    <DataGrid v-if="results" :data="results" />
  </div>
</template>
vue
<!-- src/components/QueryPanel.vue -->
<script setup lang="ts">
import { ref } from 'vue'
import { invoke } from '@tauri-apps/api/core'
import { useConnectionStore } from '@/stores/connection'

const store = useConnectionStore()
const sql = ref('')
const results = ref(null)
const error = ref('')
const loading = ref(false)

async function runQuery() {
  if (!sql.value.trim()) return
  loading.value = true
  error.value = ''
  try {
    results.value = await invoke('execute_query', {
      connectionId: store.activeConnectionId,
      sql: sql.value,
    })
  } catch (e) {
    error.value = String(e)
  } finally {
    loading.value = false
  }
}
</script>

<template>
  <div class="flex flex-col gap-2 h-full">
    <textarea
      v-model="sql"
      class="font-mono text-sm border rounded p-2 h-40 resize-none"
      placeholder="SELECT * FROM users LIMIT 10"
      @keydown.meta.enter="runQuery"
      @keydown.ctrl.enter="runQuery"
    />
    <button
      :disabled="loading"
      class="px-4 py-2 bg-primary text-white rounded"
      @click="runQuery"
    >
      {{ loading ? '运行中...' : '运行 (Cmd+Enter)' }}
    </button>
    <div v-if="error" class="text-red-500 text-sm">{{ error }}</div>
    <DataGrid v-if="results" :data="results" />
  </div>
</template>

Adding i18n Strings

添加国际化字符串

typescript
// src/locales/en.json
{
  "connection": {
    "new": "New Connection",
    "test": "Test Connection",
    "save": "Save"
  },
  "query": {
    "run": "Run Query",
    "history": "History"
  }
}

// src/locales/zh-CN.json
{
  "connection": {
    "new": "新建连接",
    "test": "测试连接",
    "save": "保存"
  }
}
vue
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>

<template>
  <button>{{ t('connection.new') }}</button>
</template>
typescript
// src/locales/en.json
{
  "connection": {
    "new": "New Connection",
    "test": "Test Connection",
    "save": "Save"
  },
  "query": {
    "run": "Run Query",
    "history": "History"
  }
}

// src/locales/zh-CN.json
{
  "connection": {
    "new": "新建连接",
    "test": "测试连接",
    "save": "保存"
  }
}
vue
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>

<template>
  <button>{{ t('connection.new') }}</button>
</template>

Cargo.toml Key Dependencies

Cargo.toml核心依赖

toml
[dependencies]
tauri = { version = "2", features = ["native-tls-vendored"] }
sqlx = { version = "0.7", features = ["mysql", "postgres", "sqlite", "runtime-tokio-native-tls"] }
tiberius = "0.12"          # SQL Server
redis = "0.25"             # Redis
mongodb = "2.8"            # MongoDB
duckdb = "0.10"            # DuckDB
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
toml
[dependencies]
tauri = { version = "2", features = ["native-tls-vendored"] }
sqlx = { version = "0.7", features = ["mysql", "postgres", "sqlite", "runtime-tokio-native-tls"] }
tiberius = "0.12"          # SQL Server
redis = "0.25"             # Redis
mongodb = "2.8"            # MongoDB
duckdb = "0.10"            # DuckDB
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }

Troubleshooting

故障排除

Build Fails on macOS (Rust linker error)

macOS上构建失败(Rust链接器错误)

bash
xcode-select --install
bash
xcode-select --install

Then retry:

然后重试:

pnpm tauri build
undefined
pnpm tauri build
undefined

"Connection refused" on localhost

本地主机“连接被拒绝”

  • Check the database service is running:
    brew services list
    or
    systemctl status mysql
  • Verify port isn't blocked:
    lsof -i :5432
  • For Docker: ensure port is mapped
    -p 5432:5432
  • 检查数据库服务是否运行:
    brew services list
    systemctl status mysql
  • 验证端口未被占用:
    lsof -i :5432
  • 对于Docker:确保端口已映射
    -p 5432:5432

SQLite "database is locked"

SQLite“数据库已锁定”

Close any other applications (like DB Browser for SQLite) with the file open before connecting in DBX.
在DBX中连接前,关闭所有其他打开该文件的应用(如DB Browser for SQLite)。

macOS App Won't Open (Gatekeeper)

macOS应用无法打开(Gatekeeper)

bash
xattr -cr /Applications/dbx.app
bash
xattr -cr /Applications/dbx.app

Redis AUTH Error

Redis认证错误

Ensure the connection string includes the password:
redis://:yourpassword@localhost:6379
确保连接字符串包含密码:
redis://:yourpassword@localhost:6379

MongoDB Atlas Connection

MongoDB Atlas连接

Use the full SRV connection string from Atlas → Connect → Drivers:
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/mydb?retryWrites=true&w=majority
使用Atlas提供的完整SRV连接字符串 → 连接 → 驱动程序:
mongodb+srv://username:password@cluster0.xxxxx.mongodb.net/mydb?retryWrites=true&w=majority

pnpm install Fails

pnpm install失败

bash
node --version   # Must be >= 18
pnpm --version   # Install: npm i -g pnpm
rustup update    # Keep Rust current
bash
node --version   # 必须 >= 18
pnpm --version   # 安装:npm i -g pnpm
rustup update    # 保持Rust为最新版本

Query History Not Showing

查询历史未显示

History is stored in Tauri's app data directory:
  • macOS:
    ~/Library/Application Support/dbx/
  • Linux:
    ~/.local/share/dbx/
  • Windows:
    %APPDATA%\dbx\
历史记录存储在Tauri的应用数据目录中:
  • macOS:
    ~/Library/Application Support/dbx/
  • Linux:
    ~/.local/share/dbx/
  • Windows:
    %APPDATA%\dbx\

Contributing

贡献指南

bash
undefined
bash
undefined

Fork & clone

Fork并克隆仓库

git clone https://github.com/YOUR_USERNAME/dbx.git cd dbx pnpm install
git clone https://github.com/YOUR_USERNAME/dbx.git cd dbx pnpm install

Create feature branch

创建功能分支

git checkout -b feat/my-new-database-driver
git checkout -b feat/my-new-database-driver

Run in dev mode with hot reload

以热重载的开发模式运行

pnpm tauri dev
pnpm tauri dev

Run frontend only (no Rust)

仅运行前端(无Rust)

pnpm dev
pnpm dev

Type check

类型检查

pnpm vue-tsc --noEmit
pnpm vue-tsc --noEmit

Submit PR to t8y2/dbx main branch

提交PR到t8y2/dbx的main分支

undefined
undefined