docs: add VitePress documentation site with i18n

Full documentation site with English and Chinese versions:
- Home page with feature cards and screenshots
- 17 guide pages per language covering all features
- Local search, language switcher, sidebar navigation
This commit is contained in:
t8y2
2026-05-03 16:54:36 +08:00
parent 26429aa5d6
commit c1f7349c5c
44 changed files with 4515 additions and 0 deletions
+3
View File
@@ -0,0 +1,3 @@
node_modules/
.vitepress/dist/
.vitepress/cache/
+160
View File
@@ -0,0 +1,160 @@
import { defineConfig } from 'vitepress'
export default defineConfig({
title: 'DBX',
description: 'Open-source, lightweight, cross-platform database management tool',
base: '/dbx/',
head: [
['link', { rel: 'icon', href: '/dbx/logo.png' }],
],
locales: {
root: {
label: 'English',
lang: 'en',
themeConfig: {
nav: [
{ text: 'Guide', link: '/guide/what-is-dbx' },
{
text: 'Features',
items: [
{ text: 'Database Support', link: '/guide/databases' },
{ text: 'Query Editor', link: '/guide/query-editor' },
{ text: 'Data Grid', link: '/guide/data-grid' },
{ text: 'Schema Diff', link: '/guide/schema-diff' },
{ text: 'Data Transfer', link: '/guide/data-transfer' },
{ text: 'AI Assistant', link: '/guide/ai-assistant' },
{ text: 'MCP Integration', link: '/guide/mcp' },
],
},
{ text: 'Changelog', link: 'https://github.com/t8y2/dbx/releases' },
{ text: 'Download', link: 'https://github.com/t8y2/dbx/releases' },
],
sidebar: [
{
text: 'Introduction',
items: [
{ text: 'What is DBX?', link: '/guide/what-is-dbx' },
{ text: 'Getting Started', link: '/guide/getting-started' },
{ text: 'Database Support', link: '/guide/databases' },
],
},
{
text: 'Core Features',
items: [
{ text: 'Query Editor', link: '/guide/query-editor' },
{ text: 'Data Grid', link: '/guide/data-grid' },
{ text: 'Schema Browser', link: '/guide/schema-browser' },
],
},
{
text: 'Advanced Features',
items: [
{ text: 'Schema Diff', link: '/guide/schema-diff' },
{ text: 'Data Transfer', link: '/guide/data-transfer' },
{ text: 'Table Structure Editor', link: '/guide/table-structure' },
{ text: 'Field Lineage', link: '/guide/field-lineage' },
{ text: 'Table Import', link: '/guide/table-import' },
{ text: 'SQL File Execution', link: '/guide/sql-file' },
{ text: 'Database Export', link: '/guide/database-export' },
],
},
{
text: 'AI & Automation',
items: [
{ text: 'AI Assistant', link: '/guide/ai-assistant' },
{ text: 'MCP Integration', link: '/guide/mcp' },
],
},
{
text: 'Settings',
items: [
{ text: 'Config Export/Import', link: '/guide/config-export' },
{ text: 'SSH Tunnel', link: '/guide/ssh-tunnel' },
],
},
],
},
},
'zh-CN': {
label: '简体中文',
lang: 'zh-CN',
themeConfig: {
nav: [
{ text: '指南', link: '/zh-CN/guide/what-is-dbx' },
{
text: '功能',
items: [
{ text: '数据库支持', link: '/zh-CN/guide/databases' },
{ text: '查询编辑器', link: '/zh-CN/guide/query-editor' },
{ text: '数据表格', link: '/zh-CN/guide/data-grid' },
{ text: 'Schema 对比', link: '/zh-CN/guide/schema-diff' },
{ text: '数据传输', link: '/zh-CN/guide/data-transfer' },
{ text: 'AI 助手', link: '/zh-CN/guide/ai-assistant' },
{ text: 'MCP 集成', link: '/zh-CN/guide/mcp' },
],
},
{ text: '更新日志', link: 'https://github.com/t8y2/dbx/releases' },
{ text: '下载', link: 'https://github.com/t8y2/dbx/releases' },
],
sidebar: [
{
text: '介绍',
items: [
{ text: '什么是 DBX?', link: '/zh-CN/guide/what-is-dbx' },
{ text: '快速开始', link: '/zh-CN/guide/getting-started' },
{ text: '数据库支持', link: '/zh-CN/guide/databases' },
],
},
{
text: '核心功能',
items: [
{ text: '查询编辑器', link: '/zh-CN/guide/query-editor' },
{ text: '数据表格', link: '/zh-CN/guide/data-grid' },
{ text: '结构浏览', link: '/zh-CN/guide/schema-browser' },
],
},
{
text: '高级功能',
items: [
{ text: 'Schema 对比', link: '/zh-CN/guide/schema-diff' },
{ text: '数据传输', link: '/zh-CN/guide/data-transfer' },
{ text: '表结构编辑器', link: '/zh-CN/guide/table-structure' },
{ text: '字段血缘', link: '/zh-CN/guide/field-lineage' },
{ text: '表数据导入', link: '/zh-CN/guide/table-import' },
{ text: 'SQL 文件执行', link: '/zh-CN/guide/sql-file' },
{ text: '数据库导出', link: '/zh-CN/guide/database-export' },
],
},
{
text: 'AI 与自动化',
items: [
{ text: 'AI 助手', link: '/zh-CN/guide/ai-assistant' },
{ text: 'MCP 集成', link: '/zh-CN/guide/mcp' },
],
},
{
text: '设置',
items: [
{ text: '配置导出/导入', link: '/zh-CN/guide/config-export' },
{ text: 'SSH 隧道', link: '/zh-CN/guide/ssh-tunnel' },
],
},
],
},
},
},
themeConfig: {
logo: '/logo.png',
socialLinks: [
{ icon: 'github', link: 'https://github.com/t8y2/dbx' },
{ icon: 'npm', link: 'https://www.npmjs.com/package/@dbx-app/mcp-server' },
],
footer: {
message: 'Released under the MIT License.',
copyright: 'Copyright © 2024-present DBX Contributors',
},
search: {
provider: 'local',
},
},
})
+45
View File
@@ -0,0 +1,45 @@
# AI Assistant
DBX has a built-in AI assistant that helps you write, explain, optimize, and fix SQL queries.
## Setup
1. Click the **Settings** icon in the toolbar
2. Go to **AI Settings**
3. Choose your provider (Claude or OpenAI)
4. Enter your API key
5. Select a model
## Features
### Natural Language to SQL
Describe what you want to query in plain language:
> "Show me the top 10 customers by total order amount"
The AI assistant will generate the SQL based on your database schema.
### Explain SQL
Select a SQL query and ask the AI to explain what it does.
### Optimize SQL
Get suggestions for improving query performance.
### Fix Errors
When a query fails, click **Fix with AI** to get a corrected version.
## Supported Providers
| Provider | Models |
|---|---|
| Anthropic (Claude) | Claude 4 Opus, Claude 4 Sonnet, Claude 3.5 Haiku |
| OpenAI | GPT-4o, GPT-4o-mini, o3-mini |
| Compatible | Any OpenAI-compatible API endpoint |
## Beyond Built-in AI
For a more powerful AI-driven database experience, try the [MCP integration](/guide/mcp). It lets AI coding agents like Claude Code and Cursor directly query your databases and open results in DBX.
+31
View File
@@ -0,0 +1,31 @@
# Config Export/Import
Export your database connections (with encrypted passwords) to migrate between machines.
## Export
1. Click the **Export** button (↓) in the sidebar header
2. Enter a passphrase to encrypt your passwords
3. Choose a save location
4. The exported file contains all connections with passwords, encrypted
## Import
1. Click the **Import** button (↑) in the sidebar header
2. Select the exported file
3. If encrypted, enter the passphrase
4. Connections are imported with passwords restored
## Security
- Passwords are encrypted using AES-256-GCM with PBKDF2 key derivation
- Without the passphrase, the file cannot be decrypted
- The export file is a standard JSON file that can be transferred via USB drive, cloud storage, etc.
## Backward Compatibility
Import also supports:
- Plain JSON files exported from older versions (without passwords)
- Raw connection config arrays
Connections are deduplicated by name + host + port during import.
+45
View File
@@ -0,0 +1,45 @@
# Data Grid
The Data Grid displays query results and table data in a high-performance, spreadsheet-like interface. It supports browsing large datasets, inline editing, and exporting data in multiple formats.
## Virtual Scrolling
The grid uses virtual scrolling to handle large result sets efficiently. Only the rows visible on screen are rendered at any given time, so performance remains consistent whether you are viewing 100 rows or 100,000 rows.
## Inline Editing
You can edit data directly in the grid without writing SQL manually. The following operations are supported:
- **UPDATE** -- Click a cell to modify its value. Changed cells are highlighted to indicate pending modifications.
- **INSERT** -- Add a new row at the bottom of the grid and fill in cell values.
- **DELETE** -- Select one or more rows and mark them for deletion.
### SQL Preview Before Saving
Before any changes are committed to the database, DBX shows a preview of the exact SQL statements that will be executed (`UPDATE`, `INSERT`, or `DELETE`). You can review the generated SQL and confirm or cancel.
## Sorting
Click a column header to sort by that column. Click again to toggle between ascending and descending order.
## Search and Filtering
- **Search** -- Use the search bar to find text across all visible columns.
- **WHERE Filter** -- Apply a custom `WHERE` clause to filter data at the database level. This is more efficient than client-side search for large tables because only matching rows are fetched.
## Column Resize and Row Numbers
- Drag column borders to resize columns to your preferred width.
- Row numbers are displayed in the leftmost column for easy reference.
## Export
Export the current result set in one of the following formats:
| Format | Description |
|---|---|
| CSV | Comma-separated values, compatible with Excel and other spreadsheet tools |
| JSON | Array of objects, suitable for use in code or APIs |
| Markdown | Markdown table, useful for pasting into documentation or chat |
Use the export button in the grid toolbar and select the desired format.
+29
View File
@@ -0,0 +1,29 @@
# Data Transfer
Data Transfer moves data between two database connections, even when they use different database engines. This is useful for migrating data, populating a development environment, or consolidating data from multiple sources.
## Setting Up a Transfer
1. Select the **source** connection and database.
2. Select the **target** connection and database.
3. Choose the tables you want to transfer.
You can transfer all tables at once or pick a subset. DBX handles the necessary type mapping between different database engines automatically.
## Cross-Engine Support
Data Transfer works across different database engines. For example, you can transfer data from MySQL to PostgreSQL, or from SQLite to SQL Server. DBX translates data types and adapts insert statements as needed for the target engine.
## Progress Tracking
During the transfer, a progress indicator shows:
- Which table is currently being transferred
- How many rows have been transferred so far
- The overall progress across all selected tables
This lets you monitor long-running transfers without guessing how much work remains.
## Error Handling
If an error occurs during transfer (for example, a type incompatibility or a constraint violation), DBX reports the error with details about which table and row caused the problem. The transfer can be reviewed and retried after correcting the issue.
+38
View File
@@ -0,0 +1,38 @@
# Database Export
Database Export generates a SQL dump of your database, including table definitions (DDL) and row data. The output is a `.sql` file that can be used to recreate the database or transfer it to another environment.
## What Gets Exported
The export includes:
- **DDL (Data Definition Language)** -- `CREATE TABLE` statements for all tables, including columns, types, defaults, constraints, and indexes.
- **Data** -- `INSERT` statements for all rows in each table.
## Batched INSERT Statements
To keep the export file manageable and compatible with database import tools, row data is written as batched `INSERT` statements. Instead of one `INSERT` per row, multiple rows are grouped into a single statement:
```sql
INSERT INTO users (id, name, email) VALUES
(1, 'Alice', 'alice@example.com'),
(2, 'Bob', 'bob@example.com'),
(3, 'Carol', 'carol@example.com');
```
This reduces file size and improves import performance.
## Configurable Row Limit
You can set a maximum number of rows to export per table. This is useful when you need a representative sample of data rather than a full dump, or when working with very large tables where a complete export would be impractical.
Set the row limit to `0` or leave it blank to export all rows.
## Usage
1. Select the connection and database to export.
2. Configure the row limit (optional).
3. Choose the output file location.
4. Start the export.
The generated `.sql` file can be executed in DBX using the [SQL File Execution](./sql-file.md) feature, or in any compatible database client.
+51
View File
@@ -0,0 +1,51 @@
# Database Support
DBX supports 13+ database engines through native Rust drivers.
## Fully Supported
| Database | Driver | Protocol |
|---|---|---|
| MySQL | sqlx | MySQL |
| PostgreSQL | sqlx | PostgreSQL |
| SQLite | sqlx | Embedded |
| Redis | redis-rs | RESP |
| MongoDB | mongodb | MongoDB Wire |
| DuckDB | duckdb-rs | Embedded |
| ClickHouse | HTTP client | HTTP |
| SQL Server | tiberius | TDS |
| Oracle | oracle-rs | OCI |
| Elasticsearch | HTTP client | REST |
## MySQL Compatible
These databases use MySQL protocol and work with the MySQL driver:
| Database | Default Port |
|---|---|
| MariaDB | 3306 |
| TiDB | 4000 |
| OceanBase | 2881 |
| GoldenDB | 3306 |
| Doris | 9030 |
| SelectDB | 9030 |
| StarRocks | 9030 |
| TDengine | 6030 |
## PostgreSQL Compatible
These databases use PostgreSQL protocol and work with the PostgreSQL driver:
| Database | Default Port | Notes |
|---|---|---|
| openGauss | 5432 | |
| GaussDB | 5432 | |
| KingBase | 54321 | |
| Vastbase | 5432 | |
| Redshift | 5439 | |
| CockroachDB | 26257 | |
| DM (Dameng) | 5236 | Requires PG compatibility mode |
::: tip DM (Dameng) Note
DM database requires PG compatibility mode to be enabled. Set `COMPATIBLE_MODE=7` in `dm.ini` and restart the service.
:::
+34
View File
@@ -0,0 +1,34 @@
# Field Lineage
Field Lineage helps you understand how columns in your database relate to each other. It traces relationships across foreign keys, views, and query history to give you a complete picture of where data comes from and where it flows.
## Relationship Sources
DBX discovers column relationships from multiple sources, each with a different confidence level:
### Foreign Key Relationships (Certain)
Relationships defined by foreign key constraints in the database schema. These are authoritative and marked with **certain** confidence because they are explicitly declared in the schema.
### View References (Likely)
When a view references columns from underlying tables, DBX traces those references. These relationships are marked with **likely** confidence because they are derived from view definitions rather than explicit constraints.
### Query History References
DBX analyzes your local query history to identify columns that are frequently joined or referenced together. These relationships are inferred from usage patterns.
### Same-Name Column Detection
Columns that share the same name across different tables are flagged as potential relationships. This heuristic is useful for discovering implicit conventions (such as `user_id` appearing in multiple tables) that are not enforced by foreign keys.
## Searching and Filtering
The lineage panel provides:
- **Search** -- Filter relationships by table name or column name.
- **Confidence filter** -- Show only relationships at a specific confidence level (certain, likely, or all). This lets you focus on verified relationships or explore speculative ones.
## Click-Through Navigation
Click any related table or column in the lineage view to navigate directly to it. This opens the target table in the Data Grid or Schema Browser, making it easy to follow data relationships across your schema without manually searching.
+71
View File
@@ -0,0 +1,71 @@
# Getting Started
## Install
Download the latest release from the [Releases](https://github.com/t8y2/dbx/releases) page.
### Homebrew (macOS)
```bash
brew install --cask t8y2/tap/dbx
```
Update:
```bash
brew upgrade --cask t8y2/tap/dbx
```
### Scoop (Windows)
```bash
scoop bucket add dbx https://github.com/t8y2/scoop-bucket
scoop install dbx
```
Update:
```bash
scoop update dbx
```
### macOS Note
DBX is not signed with an Apple Developer certificate. On first launch, macOS will block the app. To fix:
```bash
xattr -cr /Applications/dbx.app
```
Or: **System Settings → Privacy & Security → Open Anyway**.
## Create Your First Connection
1. Click **New Connection** in the toolbar
2. Select your database type (MySQL, PostgreSQL, etc.)
3. Fill in host, port, username, password
4. Click **Test** to verify the connection
5. Click **Save & Connect**
## Development Setup
### Prerequisites
- [Node.js](https://nodejs.org/) >= 18
- [pnpm](https://pnpm.io/)
- [Rust](https://www.rust-lang.org/tools/install) >= 1.77
### Run
```bash
git clone https://github.com/t8y2/dbx.git
cd dbx
pnpm install
pnpm tauri dev
```
### Build
```bash
pnpm tauri build
```
The installer will be in `src-tauri/target/release/bundle/`.
+179
View File
@@ -0,0 +1,179 @@
# MCP Integration
## What is MCP?
MCP (Model Context Protocol) is an open protocol that lets AI coding agents (Claude Code, Cursor, etc.) call external tools. DBX's MCP Server exposes your database connections to AI agents, so you can query databases using natural language without writing SQL manually.
```
You: "Show me the order volume trend for the last 7 days"
AI Agent → MCP Server → Your Database → Results
↓
DBX connection configs (with passwords)
```
## Quick Start
### 1. Install
```bash
npm install -g @dbx-app/mcp-server
```
### 2. Configure Your AI Agent
Create `.mcp.json` in your working directory:
```json
{
"mcpServers": {
"dbx": {
"command": "npx",
"args": ["-y", "@dbx-app/mcp-server"]
}
}
}
```
### 3. Start Using
Just ask your AI agent:
- "List my database connections"
- "Show the tables in my local-pg connection"
- "Describe the users table"
- "Query the average salary from employees"
- "Open the orders table" (requires DBX running)
## Supported AI Agents
| Agent | Status | Configuration |
|---|---|---|
| Claude Code | ✅ Native | `.mcp.json` |
| Cursor | ✅ Supported | `.cursor/mcp.json` |
| Windsurf | ✅ Supported | `.windsurfrules` |
| VS Code + Copilot | ✅ Supported | MCP extension |
## Tools
### `dbx_list_connections`
List all database connections configured in DBX.
**Example:**
> "List my database connections"
**Response:**
```
| Name | Type | Host | Port | Database |
| -------- | -------- | --------- | ---- | -------- |
| local-pg | postgres | 127.0.0.1 | 5432 | |
| prod-db | mysql | db.example| 3306 | myapp |
```
### `dbx_list_tables`
List tables and views for a connection.
| Parameter | Required | Description |
|---|---|---|
| `connection_name` | Yes | DBX connection name |
| `schema` | No | Schema name (default: public) |
### `dbx_describe_table`
Get column definitions for a table.
| Parameter | Required | Description |
|---|---|---|
| `connection_name` | Yes | DBX connection name |
| `table` | Yes | Table name |
| `schema` | No | Schema name (default: public) |
**Response:**
```
| Column | Type | Nullable | Default | Comment |
| ----------- | --------- | -------- | ------- | ---------- |
| id (PK) | integer | NO | | |
| user_id | integer | NO | | User ID |
| total | numeric | NO | 0 | Order total|
| created_at | timestamp | NO | now() | |
```
### `dbx_execute_query`
Execute a SQL query and return results (max 100 rows).
| Parameter | Required | Description |
|---|---|---|
| `connection_name` | Yes | DBX connection name |
| `sql` | Yes | SQL query |
### `dbx_open_table`
Open a table in DBX desktop app UI. **Requires DBX to be running.**
| Parameter | Required | Description |
|---|---|---|
| `connection_name` | Yes | DBX connection name |
| `table` | Yes | Table name |
| `database` | No | Database name |
| `schema` | No | Schema name |
DBX will open a new tab with the table data and bring the window to front.
### `dbx_execute_and_show`
Execute a SQL query in DBX desktop app UI. **Requires DBX to be running.**
| Parameter | Required | Description |
|---|---|---|
| `connection_name` | Yes | DBX connection name |
| `sql` | Yes | SQL query |
| `database` | No | Database name |
## How It Works
### Connection Configs
The MCP Server reads DBX's connection config files:
| Platform | Path |
|---|---|
| macOS | `~/Library/Application Support/com.dbx.app/connections.json` |
| Linux | `~/.config/com.dbx.app/connections.json` |
| Windows | `%APPDATA%\com.dbx.app\connections.json` |
Passwords are retrieved from the system keyring (macOS Keychain / Linux Secret Service / Windows Credential Manager).
### UI Integration
`dbx_open_table` and `dbx_execute_and_show` communicate with the running DBX app via a local HTTP interface:
```
AI Agent → MCP Server → HTTP localhost → DBX backend → Tauri event → Frontend opens tab
```
### Supported Databases
MCP query support: PostgreSQL, MySQL, and compatible databases (Doris, StarRocks, etc.). UI integration (open table) supports all database types in DBX.
## FAQ
**MCP Server can't connect to my database**
: Check that the connection works in DBX first. The MCP Server uses the same config and credentials.
**`dbx_open_table` says "DBX is not running"**
: Start the DBX desktop app first. UI integration requires DBX's local HTTP service.
**Connection name not found**
: Connection name matching is case-insensitive but must match exactly. Use `dbx_list_connections` to see all available names.
**Query timeout**
: MCP Server has a 30-second query timeout. Consider adding indexes or simplifying your query.
## Requirements
- [DBX](https://github.com/t8y2/dbx) installed with at least one connection configured
- Node.js 18+
- UI integration requires DBX v0.3.9+
+43
View File
@@ -0,0 +1,43 @@
# Query Editor
The Query Editor is the primary workspace for writing and executing SQL in DBX. It is built on CodeMirror 6, providing a fast, modern editing experience with deep database awareness.
## Syntax Highlighting
The editor applies language-aware syntax highlighting for SQL. Keywords, identifiers, strings, numbers, and comments are visually distinguished, making queries easier to read and write.
## Autocomplete
As you type, the editor suggests completions drawn from your actual database metadata:
- **Keywords** -- standard SQL keywords (`SELECT`, `FROM`, `WHERE`, etc.)
- **Table names** -- all tables and views visible in the current connection
- **Column names** -- columns scoped to the tables referenced in your query
- **JOIN suggestions** -- when typing a `JOIN` clause, the editor suggests related tables and join conditions based on foreign key relationships
Completions appear automatically and can also be triggered manually with the platform shortcut.
## Executing Queries
| Action | Shortcut |
|---|---|
| Execute the current query | `Cmd+Enter` (macOS) / `Ctrl+Enter` (Windows/Linux) |
| Execute selected text | Select text, then `Cmd+Enter` / `Ctrl+Enter` |
When no text is selected, the editor executes the full content of the editor. When a portion of text is selected, only that selection is executed. This is useful for running a single statement out of a multi-statement script.
Results appear immediately below the editor in the Data Grid.
## SQL Formatting
Use the format button in the toolbar to auto-format your SQL. The formatter standardizes indentation, keyword casing, and line breaks so that complex queries are easier to read and review.
## Query History
Every executed query is recorded in your local query history. You can open the history panel to:
- Browse previously executed queries
- Search through past queries by keyword
- Re-open a previous query in the editor with a single click
Query history is stored per connection, so switching connections shows only the relevant history.
+42
View File
@@ -0,0 +1,42 @@
# Schema Browser
The Schema Browser is the sidebar panel that lets you explore the structure of all your connected databases. It presents your database objects in a navigable tree and provides quick actions via context menus.
## Tree View
The browser organizes objects in a hierarchical tree:
```
Connection
+-- Database
+-- Schema
+-- Tables
| +-- Table
| +-- Column (type, nullable, default)
+-- Views
```
Expand any node to drill down into its children. Column entries display their data type and other attributes inline.
## Search and Pin
- **Search** -- Use the search field at the top of the sidebar to filter the tree. The filter applies across all connections and matches table names, view names, and column names.
- **Pin** -- Pin frequently used tables or views to keep them at the top of the sidebar for quick access, regardless of how deep they are in the tree.
## Context Menus
Right-click any node in the tree to access context-specific actions. Examples include:
- **Table** -- Open data, open structure, copy table name, drop table
- **Column** -- Copy column name
- **Connection** -- Refresh metadata, disconnect
The available actions depend on the type of object selected.
## Column Comments
If your database supports column comments (e.g., MySQL `COMMENT`, PostgreSQL `COMMENT ON COLUMN`), the Schema Browser displays them alongside each column. This makes it easy to understand the purpose of columns without leaving the sidebar.
## Connection Colors
Each connection can be assigned a color. The color is displayed as a visual indicator in the tree and in tabs, helping you distinguish between environments (for example, green for development and red for production) at a glance.
+32
View File
@@ -0,0 +1,32 @@
# Schema Diff
Schema Diff compares the structure of two databases and generates the SQL needed to synchronize them. This is useful for identifying differences between development and production environments, or between any two database instances.
## Comparing Schemas
To start a comparison:
1. Open the Schema Diff panel.
2. Select the **source** connection and database.
3. Select the **target** connection and database.
4. Run the comparison.
DBX analyzes both schemas and presents a side-by-side diff of all structural differences, including:
- Tables that exist in one database but not the other
- Columns that differ in type, default value, or nullability
- Index and constraint differences
## Generating Sync SQL
After the comparison is complete, DBX generates the SQL statements required to bring the target database in line with the source. This may include `CREATE TABLE`, `ALTER TABLE`, `DROP TABLE`, and related statements depending on the differences found.
You can review the generated SQL before taking any action.
## Executing Sync Directly
Once you have reviewed the generated SQL, you can execute it directly within DBX against the target database. There is no need to copy the SQL to an external tool -- the sync can be completed in a single workflow.
::: warning
Schema sync can make destructive changes (such as dropping tables or columns). Always review the generated SQL carefully before executing, and consider backing up the target database first.
:::
+34
View File
@@ -0,0 +1,34 @@
# SQL File Execution
SQL File Execution lets you run `.sql` files directly within DBX, with progress tracking and the ability to cancel mid-execution. This is useful for running migration scripts, seed data, or database setup files.
## Running a SQL File
1. Open the SQL File Execution panel.
2. Select a `.sql` file from your filesystem.
3. Choose the target connection and database.
4. Click execute.
## Progress Tracking
During execution, DBX displays:
- The total number of statements detected in the file
- How many statements have been executed so far
- The currently executing statement
This gives you visibility into long-running scripts without waiting blindly for completion.
## Smart Statement Splitting
DBX parses the SQL file intelligently rather than naively splitting on semicolons. The parser correctly handles:
- **Functions and procedures** -- Multi-statement bodies with `BEGIN...END` blocks are treated as a single unit.
- **Triggers** -- `CREATE TRIGGER` statements with embedded logic are kept intact.
- **Quoted strings** -- Semicolons inside string literals or identifiers are not treated as statement delimiters.
This ensures that complex SQL files execute correctly without requiring manual editing.
## Cancelling Execution
If you need to stop execution before the file finishes, click the cancel button. DBX will stop after the current statement completes. Statements that have already been executed are not rolled back.
+46
View File
@@ -0,0 +1,46 @@
# SSH Tunnel
DBX can connect to databases through an SSH tunnel, allowing you to securely access database servers that are not directly reachable from your machine. This is common in production environments where the database is behind a firewall or on a private network.
## Configuration
When creating or editing a connection, enable the SSH tunnel option and provide the following details:
| Field | Description |
|---|---|
| SSH Host | Hostname or IP address of the SSH server |
| SSH Port | Port for the SSH connection (default: 22) |
| SSH User | Username for SSH authentication |
| Authentication | Password or private key |
## Authentication Methods
### Password
Enter your SSH password directly. The password is stored securely alongside your connection configuration.
### Private Key
Select a private key file (e.g., `~/.ssh/id_rsa`, `~/.ssh/id_ed25519`) using the file picker. You do not need to type the path manually -- click the browse button to select the key file from your filesystem.
#### Key Passphrase
If your private key is protected by a passphrase, DBX will prompt you to enter it. The passphrase is used to decrypt the key at connection time.
## Expose Tunnel to LAN
By default, the SSH tunnel listens only on `localhost` (`127.0.0.1`). If you enable the **Expose to LAN** option, the tunnel binds to `0.0.0.0`, making it accessible to other devices on your local network.
::: warning
Exposing the tunnel to your LAN means any device on the same network can access the tunneled database port. Only enable this on trusted networks.
:::
## How It Works
When you connect, DBX:
1. Establishes an SSH connection to the specified SSH server.
2. Creates a local port that forwards traffic through the SSH tunnel to the database server.
3. Connects to the database through the forwarded local port.
The tunnel remains active for the duration of the database connection and is closed automatically when you disconnect.
+37
View File
@@ -0,0 +1,37 @@
# Table Import
Table Import lets you load data from local files into a database table. It supports common file formats and provides column mapping to ensure data lands in the right place.
## Supported Formats
| Format | Extensions |
|---|---|
| CSV | `.csv` |
| TSV | `.tsv` |
| JSON | `.json` |
| Excel | `.xlsx`, `.xls` |
## Import Workflow
1. Select the target connection, database, and table.
2. Choose a file to import.
3. Review the auto-generated column mapping.
4. Select the import mode.
5. Start the import.
## Column Mapping
After selecting a file, DBX reads the file headers (or keys, for JSON) and automatically maps them to columns in the target table by matching names. You can adjust the mapping manually if the names do not match exactly.
Unmapped file columns are skipped. Unmapped table columns receive their default value or NULL.
## Import Modes
| Mode | Behavior |
|---|---|
| **Append** | Insert the imported rows into the table alongside existing data. |
| **Truncate then import** | Delete all existing rows from the table first, then insert the imported data. |
::: warning
Truncate mode permanently removes all existing data in the target table before importing. Make sure this is the intended behavior before proceeding.
:::
+43
View File
@@ -0,0 +1,43 @@
# Table Structure Editor
The Table Structure Editor provides a visual interface for modifying table schemas. Instead of writing `ALTER TABLE` statements by hand, you can add, modify, and delete columns and indexes through a form-based UI.
## Column Editor
The column editor displays all columns of the selected table in an editable list. For each column, you can modify:
- **Name** -- Rename the column
- **Type** -- Change the data type
- **Nullable** -- Toggle whether the column allows NULL values
- **Default** -- Set or change the default value
- **Comment** -- Add or update the column comment (on supported engines)
You can also:
- **Add a column** -- Append a new column definition to the table
- **Delete a column** -- Remove an existing column from the table
## Index Management
Below the column list, the index section lets you manage table indexes:
- View existing indexes and their columns
- Create new indexes (unique, non-unique)
- Remove existing indexes
## SQL Preview
Before applying any structural changes, DBX generates and displays the corresponding SQL statements (`ALTER TABLE ADD COLUMN`, `ALTER TABLE MODIFY COLUMN`, `DROP COLUMN`, `CREATE INDEX`, etc.). You can review the exact SQL that will be executed and confirm or cancel.
## Database Support
The Table Structure Editor supports the following database engines:
| Engine | Support |
|---|---|
| MySQL | Full support |
| PostgreSQL | Full support |
| SQLite | Full support |
| SQL Server | Full support |
Behavior adapts to the capabilities and syntax of each engine. For example, SQLite's limited `ALTER TABLE` support is handled transparently by DBX.
+29
View File
@@ -0,0 +1,29 @@
# What is DBX?
DBX is an open-source, lightweight, cross-platform database management tool built with [Tauri 2](https://tauri.app/) and Rust.
<div style="text-align:center">
<img src="/screenshot.png" alt="DBX Screenshot" style="max-width:100%;border-radius:8px;margin:16px 0" />
</div>
## Why DBX?
- **Lightweight** — ~15 MB installer, no bundled Chromium
- **Multi-database** — One tool for MySQL, PostgreSQL, SQLite, Redis, MongoDB, and 8 more
- **AI-powered** — Built-in AI assistant + MCP server for external AI agents
- **Secure** — Passwords in system keyring, SSH tunnels, encrypted config export
- **Cross-platform** — macOS, Windows, Linux
## Tech Stack
| Layer | Technology |
|---|---|
| Framework | [Tauri 2](https://tauri.app/) |
| Frontend | [Vue 3](https://vuejs.org/) + TypeScript |
| UI | [shadcn-vue](https://www.shadcn-vue.com/) + Tailwind CSS |
| Editor | [CodeMirror 6](https://codemirror.net/) |
| Backend | Rust + sqlx / tiberius / redis-rs / mongodb |
## License
[MIT](https://github.com/t8y2/dbx/blob/main/LICENSE)
+101
View File
@@ -0,0 +1,101 @@
---
layout: home
hero:
name: DBX
text: Database Management Tool
tagline: Open-source, lightweight, cross-platform. Supports 13+ databases with built-in AI assistant.
image:
src: /logo.png
alt: DBX
actions:
- theme: brand
text: Get Started
link: /guide/getting-started
- theme: alt
text: Download
link: https://github.com/t8y2/dbx/releases
- theme: alt
text: GitHub
link: https://github.com/t8y2/dbx
features:
- icon: 🗄️
title: 13+ Databases
details: MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, ClickHouse, SQL Server, Oracle, Elasticsearch, and many MySQL/PG-compatible databases.
link: /guide/databases
linkText: View all databases
- icon: ✏️
title: Query Editor
details: CodeMirror 6 with syntax highlighting, smart SQL autocomplete for tables and columns, format SQL, execute selected text.
link: /guide/query-editor
linkText: Learn more
- icon: 📊
title: Data Grid
details: Virtual-scrolled table with inline editing, sorting, search, WHERE filter, pagination. Edit data and preview SQL before saving.
link: /guide/data-grid
linkText: Learn more
- icon: 🤖
title: AI Assistant
details: Natural language to SQL, explain, optimize, fix errors. Supports Claude, OpenAI, and any compatible API.
link: /guide/ai-assistant
linkText: Learn more
- icon: 🔌
title: MCP Integration
details: Let Claude Code, Cursor and other AI agents query your databases and open tables in DBX directly.
link: /guide/mcp
linkText: Setup guide
- icon: 🔄
title: Schema Diff & Transfer
details: Compare schemas across databases and generate sync SQL. Transfer data between different database engines.
link: /guide/schema-diff
linkText: Learn more
- icon: 🔍
title: Field Lineage
details: Trace column dependencies through foreign keys, views, query history, and same-name fields across tables.
link: /guide/field-lineage
linkText: Learn more
- icon: 🔒
title: Secure & Lightweight
details: Passwords in system keyring, SSH tunnel, encrypted config export. ~15 MB installer, no bundled Chromium.
link: /guide/config-export
linkText: Learn more
---
<style>
.screenshot-section {
max-width: 1152px;
margin: 0 auto;
padding: 48px 24px;
}
.screenshot-section h2 {
text-align: center;
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 24px;
}
.screenshot-section img {
width: 100%;
border-radius: 12px;
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.screenshot-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-top: 16px;
}
.screenshot-grid img {
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
</style>
<div class="screenshot-section">
<h2>See it in action</h2>
<img src="/screenshot.png" alt="DBX main interface" />
<div class="screenshot-grid">
<img src="/screenshot-connections.jpg" alt="Connection dialog" />
<img src="/screenshot-ai.jpg" alt="AI assistant" />
</div>
</div>
+2514
View File
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "dbx-docs",
"private": true,
"type": "module",
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"preview": "vitepress preview"
},
"devDependencies": {
"vitepress": "^1.6.4"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

+45
View File
@@ -0,0 +1,45 @@
# AI 助手
DBX 内置 AI 助手,帮你编写、解释、优化和修复 SQL 查询。
## 设置
1. 点击工具栏的 **设置** 图标
2. 进入 **AI 设置**
3. 选择供应商(Claude 或 OpenAI)
4. 输入 API Key
5. 选择模型
## 功能
### 自然语言转 SQL
用自然语言描述你想查询的内容:
> "查看最近 10 个订单金额最高的客户"
AI 助手会根据你的数据库结构生成 SQL。
### 解释 SQL
选中一段 SQL 查询,让 AI 解释它的作用。
### 优化 SQL
获取查询性能优化建议。
### 修复错误
查询执行失败时,点击 **AI 修复** 获取修正后的版本。
## 支持的供应商
| 供应商 | 模型 |
|---|---|
| Anthropic (Claude) | Claude 4 Opus、Claude 4 Sonnet、Claude 3.5 Haiku |
| OpenAI | GPT-4o、GPT-4o-mini、o3-mini |
| 兼容接口 | 任何 OpenAI 兼容的 API 端点 |
## 更强大的 AI 体验
除了内置 AI 助手,还可以试试 [MCP 集成](/zh-CN/guide/mcp)。它让 Claude Code、Cursor 等 AI 编程助手直接查询你的数据库,并在 DBX 中打开结果。
+31
View File
@@ -0,0 +1,31 @@
# 配置导出/导入
导出数据库连接配置(含加密密码),方便在不同电脑之间迁移。
## 导出
1. 点击侧边栏顶部的 **导出** 按钮(↓)
2. 输入密码短语来加密连接密码
3. 选择保存位置
4. 导出文件包含所有连接及密码,已加密
## 导入
1. 点击侧边栏顶部的 **导入** 按钮(↑)
2. 选择导出的文件
3. 如果文件已加密,输入密码短语
4. 连接导入完成,密码自动恢复
## 安全性
- 密码使用 AES-256-GCM 加密,密钥通过 PBKDF2 派生
- 没有密码短语无法解密文件
- 导出文件是标准 JSON 格式,可以通过 U 盘、网盘等方式传输
## 向后兼容
导入同样支持:
- 旧版本导出的明文 JSON 文件(不含密码)
- 原始的连接配置数组
导入时按 名称 + 主机 + 端口 去重。
+42
View File
@@ -0,0 +1,42 @@
# 数据表格
DBX 的数据表格组件用于浏览和编辑表中的数据,支持大数据量虚拟滚动、行内编辑、排序过滤以及多种格式导出。
## 虚拟滚动
数据表格采用虚拟滚动技术,仅渲染当前可视区域内的行,即使表中有数十万条记录也能保持流畅的滚动和操作体验。
## 行内编辑
你可以直接在表格中编辑数据,无需编写 SQL 语句:
- **修改数据** -- 双击单元格即可编辑,修改后的单元格会高亮标记
- **新增行** -- 点击工具栏中的"新增行"按钮,在表格底部插入一行空记录
- **删除行** -- 选中行后点击"删除"按钮,标记该行待删除
所有修改会暂存在本地,不会立即写入数据库。
## SQL 预览
在点击"保存"之前,你可以预览 DBX 即将执行的 SQL 语句(`UPDATE`、`INSERT`、`DELETE`),确认无误后再提交。这样可以避免误操作对数据造成不可逆的影响。
## 排序与过滤
- **排序** -- 点击列头可按该列升序或降序排列
- **搜索** -- 使用搜索框快速查找包含指定文本的行
- **WHERE 过滤** -- 输入自定义的 `WHERE` 条件,精确筛选满足条件的数据
## 列宽调整与行号
- 拖拽列头边缘可以调整列宽,以适应不同长度的数据内容
- 表格左侧显示行号,方便定位和引用
## 数据导出
选择工具栏中的导出功能,可将当前表格数据导出为以下格式:
| 格式 | 说明 |
|---|---|
| CSV | 逗号分隔的文本文件,适合导入 Excel 或其他工具 |
| JSON | JSON 数组格式,适合程序处理 |
| Markdown | Markdown 表格格式,适合粘贴到文档中 |
+34
View File
@@ -0,0 +1,34 @@
# 数据传输
DBX 支持在不同数据库引擎之间传输数据,例如将 MySQL 中的数据迁移到 PostgreSQL,或从 SQLite 导入数据到 SQL Server。
## 使用方式
1. 打开数据传输功能
2. 选择**源连接**和**目标连接**(可以是不同类型的数据库引擎)
3. 选择要传输的表
4. 点击"开始传输"
DBX 会自动处理不同数据库之间的类型映射和语法差异。
## 选择要传输的表
你可以选择传输源数据库中的全部表,也可以手动勾选需要传输的特定表。对于不需要迁移的表,取消勾选即可跳过。
## 进度追踪
传输过程中,DBX 会实时显示:
- 当前正在传输的表名
- 已传输的行数
- 整体传输进度
你可以随时查看传输状态,了解剩余工作量。
## 错误处理
如果传输过程中遇到错误(如类型不兼容、约束冲突等),DBX 会:
- 记录错误信息和对应的表名
- 继续传输其他表,不会因单个表的错误中断整个任务
- 传输完成后汇总展示所有错误,便于排查和处理
+35
View File
@@ -0,0 +1,35 @@
# 数据库导出
DBX 支持将整个数据库导出为 SQL 文件,包含表结构(DDL)和数据,适用于数据库备份和迁移。
## 导出内容
导出的 SQL 文件包含:
- **表结构(DDL)** -- `CREATE TABLE` 语句,包括列定义、主键、索引、约束等
- **表数据** -- 以 `INSERT` 语句的形式导出表中的数据
## 批量 INSERT 语句
为了提高导入效率,DBX 会将数据生成为批量 `INSERT` 语句,每条语句包含多行数据,减少执行次数,加快数据恢复速度。
示例:
```sql
INSERT INTO users (id, name, email) VALUES
(1, '张三', 'zhangsan@example.com'),
(2, '李四', 'lisi@example.com'),
(3, '王五', 'wangwu@example.com');
```
## 配置选项
### 行数限制
你可以配置每张表导出的最大行数。这在以下场景中非常有用:
- 只需要导出表结构和少量示例数据时
- 表中数据量过大,完整导出文件体积过大时
- 需要创建用于开发或测试的精简数据集时
设置为 0 或留空表示导出全部数据。
+51
View File
@@ -0,0 +1,51 @@
# 数据库支持
DBX 通过 Rust 原生驱动支持 13+ 种数据库。
## 完整支持
| 数据库 | 驱动 | 协议 |
|---|---|---|
| MySQL | sqlx | MySQL |
| PostgreSQL | sqlx | PostgreSQL |
| SQLite | sqlx | 嵌入式 |
| Redis | redis-rs | RESP |
| MongoDB | mongodb | MongoDB Wire |
| DuckDB | duckdb-rs | 嵌入式 |
| ClickHouse | HTTP client | HTTP |
| SQL Server | tiberius | TDS |
| Oracle | oracle-rs | OCI |
| Elasticsearch | HTTP client | REST |
## MySQL 兼容
以下数据库使用 MySQL 协议,通过 MySQL 驱动连接:
| 数据库 | 默认端口 |
|---|---|
| MariaDB | 3306 |
| TiDB | 4000 |
| OceanBase | 2881 |
| GoldenDB | 3306 |
| Doris | 9030 |
| SelectDB | 9030 |
| StarRocks | 9030 |
| TDengine | 6030 |
## PostgreSQL 兼容
以下数据库使用 PostgreSQL 协议,通过 PostgreSQL 驱动连接:
| 数据库 | 默认端口 | 备注 |
|---|---|---|
| openGauss | 5432 | |
| GaussDB | 5432 | |
| KingBase(人大金仓) | 54321 | |
| Vastbase | 5432 | |
| Redshift | 5439 | |
| CockroachDB | 26257 | |
| DM(达梦) | 5236 | 需开启 PG 兼容模式 |
::: tip 达梦数据库说明
达梦数据库需要开启 PG 兼容模式。在 `dm.ini` 中设置 `COMPATIBLE_MODE=7` 并重启服务。
:::
+34
View File
@@ -0,0 +1,34 @@
# 字段血缘
字段血缘功能帮助你理解数据库中字段之间的关联关系,追踪数据的来源和去向。DBX 会从多个维度自动分析字段之间的关联,并标注置信度。
## 关联来源
DBX 通过以下方式检测字段之间的关联关系:
### 外键关系(确定置信度)
基于数据库中已定义的外键约束,这是最可靠的关联来源。例如,`orders.user_id` 通过外键指向 `users.id`,这种关联是确定的。
### 视图引用(高置信度)
分析视图定义中的 SQL 语句,提取视图字段与底层表字段的映射关系。由于视图定义是明确的 SQL 逻辑,这类关联具有较高的置信度。
### 查询历史引用
从你执行过的 SQL 查询历史中,分析 `JOIN` 条件和 `WHERE` 子句,推断字段之间可能存在的关联。
### 同名字段检测
检测不同表中名称相同的字段,提示它们之间可能存在逻辑关联。这类关联的置信度相对较低,需要人工判断。
## 搜索与筛选
你可以通过以下方式快速定位关注的关联:
- **搜索** -- 输入表名或字段名,过滤显示相关的血缘关系
- **按置信度筛选** -- 选择只查看特定置信度级别的关联,例如仅显示"确定"和"高"置信度的结果
## 跳转到关联表
在血缘视图中,点击任意关联的表或字段,可以直接跳转到该表的数据浏览或结构查看页面,方便你快速了解上下游数据。
+71
View File
@@ -0,0 +1,71 @@
# 快速开始
## 安装
从 [Releases](https://github.com/t8y2/dbx/releases) 页面下载最新版本。
### Homebrew (macOS)
```bash
brew install --cask t8y2/tap/dbx
```
更新:
```bash
brew upgrade --cask t8y2/tap/dbx
```
### Scoop (Windows)
```bash
scoop bucket add dbx https://github.com/t8y2/scoop-bucket
scoop install dbx
```
更新:
```bash
scoop update dbx
```
### macOS 说明
DBX 未使用 Apple 开发者证书签名,首次打开时 macOS 会阻止运行。解决方法:
```bash
xattr -cr /Applications/dbx.app
```
或者:**系统设置 → 隐私与安全性 → 仍要打开**。
## 创建第一个连接
1. 点击工具栏的 **新建连接**
2. 选择数据库类型(MySQL、PostgreSQL 等)
3. 填写主机、端口、用户名、密码
4. 点击 **测试** 验证连接
5. 点击 **保存并连接**
## 开发环境搭建
### 环境要求
- [Node.js](https://nodejs.org/) >= 18
- [pnpm](https://pnpm.io/)
- [Rust](https://www.rust-lang.org/tools/install) >= 1.77
### 运行
```bash
git clone https://github.com/t8y2/dbx.git
cd dbx
pnpm install
pnpm tauri dev
```
### 构建
```bash
pnpm tauri build
```
安装包输出在 `src-tauri/target/release/bundle/` 目录。
+179
View File
@@ -0,0 +1,179 @@
# MCP 集成
## 什么是 MCP?
MCP(Model Context Protocol)是一个开放协议,让 AI 编程助手(Claude Code、Cursor 等)能够调用外部工具。DBX 的 MCP Server 把你在 DBX 中配置的数据库连接暴露给 AI 助手,这样你可以用自然语言查询数据库,而不需要手动写 SQL。
```
你:"查看 orders 表最近 7 天的订单量趋势"
AI 助手 → MCP Server → 你的数据库 → 返回结果
↓
DBX 的连接配置(含密码)
```
## 快速开始
### 1. 安装
```bash
npm install -g @dbx-app/mcp-server
```
### 2. 配置 AI 助手
在你的工作目录创建 `.mcp.json`:
```json
{
"mcpServers": {
"dbx": {
"command": "npx",
"args": ["-y", "@dbx-app/mcp-server"]
}
}
}
```
### 3. 开始使用
在 AI 助手中直接说:
- "列出我的数据库连接"
- "查看 local-pg 上有哪些表"
- "查看 users 表的结构"
- "查询最近 7 天的订单数量"
- "打开 orders 表"(需要 DBX 运行中)
## 支持的 AI 助手
| 助手 | 支持情况 | 配置方式 |
|---|---|---|
| Claude Code | ✅ 原生支持 | `.mcp.json` |
| Cursor | ✅ 支持 | `.cursor/mcp.json` |
| Windsurf | ✅ 支持 | `.windsurfrules` |
| VS Code + Copilot | ✅ 支持 | MCP 扩展 |
## 工具列表
### `dbx_list_connections`
列出 DBX 中所有已配置的数据库连接。
**示例对话:**
> "列出我的数据库连接"
**返回:**
```
| Name | Type | Host | Port | Database |
| -------- | -------- | --------- | ---- | -------- |
| local-pg | postgres | 127.0.0.1 | 5432 | |
| prod-db | mysql | db.example| 3306 | myapp |
```
### `dbx_list_tables`
列出指定连接的表和视图。
| 参数 | 必填 | 说明 |
|---|---|---|
| `connection_name` | 是 | DBX 连接名称 |
| `schema` | 否 | Schema 名称(默认 public) |
### `dbx_describe_table`
获取表的列定义。
| 参数 | 必填 | 说明 |
|---|---|---|
| `connection_name` | 是 | DBX 连接名称 |
| `table` | 是 | 表名 |
| `schema` | 否 | Schema 名称(默认 public) |
**返回:**
```
| Column | Type | Nullable | Default | Comment |
| ----------- | --------- | -------- | ------- | ------- |
| id (PK) | integer | NO | | |
| user_id | integer | NO | | 用户 ID |
| total | numeric | NO | 0 | 订单金额 |
| created_at | timestamp | NO | now() | |
```
### `dbx_execute_query`
执行 SQL 查询,返回结果(最多 100 行)。
| 参数 | 必填 | 说明 |
|---|---|---|
| `connection_name` | 是 | DBX 连接名称 |
| `sql` | 是 | SQL 查询语句 |
### `dbx_open_table`
在 DBX 桌面端打开指定表。**需要 DBX 正在运行。**
| 参数 | 必填 | 说明 |
|---|---|---|
| `connection_name` | 是 | DBX 连接名称 |
| `table` | 是 | 表名 |
| `database` | 否 | 数据库名 |
| `schema` | 否 | Schema 名称 |
DBX 会自动新开一个 tab 显示数据,窗口自动置前。
### `dbx_execute_and_show`
在 DBX 桌面端执行 SQL 并展示结果。**需要 DBX 正在运行。**
| 参数 | 必填 | 说明 |
|---|---|---|
| `connection_name` | 是 | DBX 连接名称 |
| `sql` | 是 | SQL 查询语句 |
| `database` | 否 | 数据库名 |
## 工作原理
### 连接配置
MCP Server 从 DBX 的配置目录读取连接信息:
| 平台 | 路径 |
|---|---|
| macOS | `~/Library/Application Support/com.dbx.app/connections.json` |
| Linux | `~/.config/com.dbx.app/connections.json` |
| Windows | `%APPDATA%\com.dbx.app\connections.json` |
密码从系统钥匙串中获取(macOS Keychain / Linux Secret Service / Windows 凭据管理器)。
### UI 联动
`dbx_open_table` 和 `dbx_execute_and_show` 通过本地 HTTP 接口与运行中的 DBX 应用通信:
```
AI 助手 → MCP Server → HTTP localhost → DBX 后端 → Tauri 事件 → 前端打开 tab
```
### 支持的数据库
MCP 查询支持 PostgreSQL 和 MySQL(及兼容数据库:Doris、StarRocks 等)。UI 联动(打开表)支持 DBX 已支持的所有数据库类型。
## 常见问题
**MCP Server 连不上数据库**
: 检查 DBX 中该连接是否能正常连接。MCP Server 使用相同的连接配置和密码。
**`dbx_open_table` 报 "DBX is not running"**
: 需要先启动 DBX 桌面应用。UI 联动功能依赖 DBX 运行时的本地 HTTP 服务。
**连接名称找不到**
: 连接名称匹配不区分大小写,但需要和 DBX 中配置的名称一致。用 `dbx_list_connections` 查看所有可用名称。
**查询超时**
: MCP Server 的查询超时为 30 秒。如果查询较慢,考虑添加索引或简化查询。
## 系统要求
- [DBX](https://github.com/t8y2/dbx) 已安装并配置了至少一个数据库连接
- Node.js 18+
- UI 联动功能需要 DBX v0.3.9+
+41
View File
@@ -0,0 +1,41 @@
# 查询编辑器
DBX 内置了基于 CodeMirror 6 的 SQL 查询编辑器,提供语法高亮、智能补全和快捷操作,帮助你高效编写和执行 SQL。
## 语法高亮
编辑器针对不同的 SQL 元素(关键字、表名、字符串、数字、注释等)提供语法着色,使 SQL 语句结构一目了然。高亮规则会根据当前连接的数据库类型自动适配。
## SQL 自动补全
在编辑器中输入时,DBX 会自动弹出补全建议,支持以下内容:
- **关键字** -- `SELECT`、`FROM`、`WHERE`、`GROUP BY` 等 SQL 关键字
- **表名** -- 当前数据库中的所有表和视图
- **字段名** -- 根据已输入的表名,自动补全对应的字段
- **JOIN 补全** -- 输入 `JOIN` 后,自动建议可关联的表及关联条件
补全列表会随着输入内容实时过滤,按 `Tab` 或 `Enter` 即可确认选择。
## 执行查询
DBX 提供多种执行方式:
| 操作 | 快捷键 |
|---|---|
| 执行当前编辑器中的全部 SQL | `Cmd+Enter`(macOS)/ `Ctrl+Enter`(Windows/Linux) |
| 仅执行选中的 SQL 片段 | 先选中文本,再按 `Cmd+Enter` |
执行结果会显示在编辑器下方的结果面板中,包括返回的数据行、执行耗时和影响行数。
## SQL 格式化
点击工具栏中的格式化按钮,可以将当前 SQL 语句自动格式化为统一的缩进和换行风格,便于阅读和维护。
## 查询历史
DBX 会自动记录你执行过的 SQL 语句。你可以:
- 在查询历史面板中浏览之前执行过的所有 SQL
- 点击某条历史记录,将其填入编辑器重新执行
- 按时间顺序查看历史记录
+40
View File
@@ -0,0 +1,40 @@
# 结构浏览
DBX 提供树形结构浏览器,让你可以快速浏览和管理数据库中的所有对象。
## 树形视图
侧边栏以树形层级展示数据库结构,层级关系如下:
```
连接
└── 数据库
└── Schema
└── 表 / 视图
└── 字段
```
点击节点可展开或折叠下级内容。点击表名可直接打开该表的数据浏览视图。
## 搜索与置顶
- **搜索** -- 在侧边栏顶部的搜索框中输入关键词,可快速过滤显示匹配的表、视图或字段
- **置顶** -- 将常用的表或连接置顶显示,方便快速访问
## 右键上下文菜单
在树形视图中右键点击节点,可以调出上下文菜单,根据节点类型提供不同的操作选项,例如:
- 打开表数据
- 查看表结构
- 复制表名
- 刷新节点
- 删除表
## 字段注释显示
如果数据库中的字段设置了注释(COMMENT),树形视图中会在字段名旁边显示对应的注释文本,帮助你理解字段含义。
## 连接颜色标记
你可以为每个数据库连接设置不同的颜色标记。颜色会显示在侧边栏的连接名称旁,便于在多个连接之间快速区分,尤其适用于区分开发环境和生产环境。
+29
View File
@@ -0,0 +1,29 @@
# Schema 对比
DBX 的 Schema 对比功能可以比较两个数据库之间的结构差异,并生成同步 SQL,帮助你快速对齐数据库结构。
## 对比两个数据库
1. 打开 Schema 对比功能
2. 分别选择**源数据库**和**目标数据库**连接
3. 点击"对比"按钮,DBX 将自动分析两个数据库中所有表和字段的差异
对比结果会以清晰的列表展示:
- **仅在源库存在的表** -- 目标库中缺少的表
- **仅在目标库存在的表** -- 源库中没有的表
- **结构不同的表** -- 字段类型、默认值、索引等存在差异的表
## 生成同步 SQL
对比完成后,DBX 会根据差异自动生成同步 SQL 语句,包括:
- `CREATE TABLE` -- 创建目标库中缺少的表
- `ALTER TABLE` -- 修改存在差异的列、索引等
- `DROP TABLE` -- 删除目标库中多余的表(可选)
你可以查看生成的 SQL 内容,确认每条语句的变更是否符合预期。
## 执行同步
确认同步 SQL 无误后,可以直接在 DBX 中执行这些语句,将目标数据库的结构同步为与源数据库一致。无需手动复制 SQL 到其他工具中运行。
+26
View File
@@ -0,0 +1,26 @@
# SQL 文件执行
DBX 支持直接执行 `.sql` 文件,适用于运行数据库迁移脚本、初始化脚本或批量 SQL 操作。
## 执行 SQL 文件
1. 打开 SQL 文件执行功能
2. 选择要执行的 `.sql` 文件
3. 选择目标数据库连接
4. 点击"执行"
执行过程中会实时显示进度,包括已执行的语句数量和当前状态。
## 智能语句分割
SQL 文件中通常包含多条语句,DBX 使用智能分割逻辑来正确解析每条语句的边界,能够正确处理以下情况:
- **函数和存储过程** -- 包含 `BEGIN...END` 块的语句不会被错误地按分号拆分
- **触发器定义** -- 使用自定义分隔符的触发器语句能被正确识别
- **引号内的字符串** -- 字符串中包含的分号不会被当作语句分隔符
这确保了即使是结构复杂的 SQL 文件也能被正确执行。
## 取消执行
如果 SQL 文件较大或执行时间较长,你可以随时点击"取消"按钮中断执行。已执行的语句不会被回滚,仅停止后续语句的执行。
+32
View File
@@ -0,0 +1,32 @@
# SSH 隧道
当数据库服务器不允许直接远程访问时,你可以通过 SSH 隧道安全地连接。DBX 内置了 SSH 隧道支持,无需手动在终端中建立隧道。
## 配置 SSH 隧道
在创建或编辑数据库连接时,启用"SSH 隧道"选项,然后填写以下信息:
- **SSH 主机** -- SSH 服务器的地址
- **SSH 端口** -- SSH 服务器的端口(默认 22)
- **SSH 用户名** -- 用于登录 SSH 服务器的用户名
## 认证方式
DBX 支持两种 SSH 认证方式:
### 密码认证
输入 SSH 用户的登录密码即可。适用于允许密码登录的服务器。
### 密钥认证
选择本地的 SSH 私钥文件进行认证:
- **密钥路径** -- 点击文件选择器,浏览并选择私钥文件(如 `~/.ssh/id_rsa`)
- **密钥密码** -- 如果私钥设置了密码保护,在此处输入密钥密码
密钥认证比密码认证更安全,推荐优先使用。
## 允许局域网访问
DBX 提供"允许局域网访问隧道"选项。启用后,同一局域网中的其他设备也可以通过你的机器访问该 SSH 隧道,适用于团队协作或需要在多个设备上共享数据库连接的场景。
+35
View File
@@ -0,0 +1,35 @@
# 表数据导入
DBX 支持将外部文件中的数据导入到数据库表中,适用于批量数据录入和数据迁移场景。
## 支持的文件格式
| 格式 | 说明 |
|---|---|
| CSV | 逗号分隔的文本文件 |
| TSV | 制表符分隔的文本文件 |
| JSON | JSON 数组格式 |
| Excel | `.xlsx` 格式的 Excel 文件 |
## 使用方式
1. 在目标表上右键,选择"导入数据"
2. 选择要导入的文件
3. 确认列映射关系
4. 选择导入模式
5. 点击"开始导入"
## 自动列映射
选择文件后,DBX 会自动将文件中的列与目标表的字段进行匹配:
- 根据列名(或表头名称)自动映射到同名字段
- 你可以手动调整映射关系,将文件中的列指向不同的目标字段
- 不需要导入的列可以取消映射
## 导入模式
DBX 提供两种导入模式:
- **追加模式** -- 将文件中的数据追加到表的现有数据之后,不影响已有记录
- **清空后导入** -- 先清空表中的所有数据,再导入文件内容。适用于需要完全替换表数据的场景
+40
View File
@@ -0,0 +1,40 @@
# 表结构编辑器
DBX 提供可视化的表结构编辑器,让你无需手写 DDL 语句即可管理表的列和索引。
## 列编辑
在表结构编辑器中,你可以通过可视化界面管理表的列:
- **添加列** -- 点击"添加列"按钮,设置列名、数据类型、是否允许 NULL、默认值等属性
- **修改列** -- 直接编辑已有列的属性,包括重命名、更改类型、调整默认值等
- **删除列** -- 选中列后点击删除,标记该列待移除
所有修改不会立即生效,而是暂存在本地等待确认。
## 索引管理
除了列之外,你还可以在同一界面中管理表的索引:
- 添加新索引,指定索引列和索引类型(普通索引、唯一索引等)
- 修改已有索引的配置
- 删除不再需要的索引
## SQL 预览
在点击"应用"之前,DBX 会展示即将执行的 `ALTER TABLE` 语句,让你确认每一项变更。你可以:
- 查看完整的 DDL 变更语句
- 确认无误后执行
- 如发现问题,返回继续调整
## 数据库支持
表结构编辑器支持以下数据库引擎,并针对各引擎的特性做了适配:
| 数据库 | 支持情况 |
|---|---|
| MySQL | 支持 |
| PostgreSQL | 支持 |
| SQLite | 支持 |
| SQL Server | 支持 |
+29
View File
@@ -0,0 +1,29 @@
# 什么是 DBX?
DBX 是一款开源、轻量、跨平台的数据库管理工具,基于 [Tauri 2](https://tauri.app/) 和 Rust 构建。
<div style="text-align:center">
<img src="/screenshot.png" alt="DBX 截图" style="max-width:100%;border-radius:8px;margin:16px 0" />
</div>
## 为什么选择 DBX?
- **轻量** — 安装包约 15 MB,不内嵌 Chromium
- **多数据库** — 一个工具管理 MySQL、PostgreSQL、SQLite、Redis、MongoDB 等 13+ 种数据库
- **AI 驱动** — 内置 AI 助手 + MCP Server 对接外部 AI 编程助手
- **安全** — 密码存储在系统钥匙串,支持 SSH 隧道,加密配置导出
- **跨平台** — macOS、Windows、Linux
## 技术栈
| 层级 | 技术 |
|---|---|
| 框架 | [Tauri 2](https://tauri.app/) |
| 前端 | [Vue 3](https://vuejs.org/) + TypeScript |
| UI | [shadcn-vue](https://www.shadcn-vue.com/) + Tailwind CSS |
| 编辑器 | [CodeMirror 6](https://codemirror.net/) |
| 后端 | Rust + sqlx / tiberius / redis-rs / mongodb |
## 开源协议
[MIT](https://github.com/t8y2/dbx/blob/main/LICENSE)
+101
View File
@@ -0,0 +1,101 @@
---
layout: home
hero:
name: DBX
text: 数据库管理工具
tagline: 开源、轻量、跨平台,支持 13+ 种数据库,内置 AI 助手
image:
src: /logo.png
alt: DBX
actions:
- theme: brand
text: 快速开始
link: /zh-CN/guide/getting-started
- theme: alt
text: 下载
link: https://github.com/t8y2/dbx/releases
- theme: alt
text: GitHub
link: https://github.com/t8y2/dbx
features:
- icon: 🗄️
title: 13+ 种数据库
details: MySQL、PostgreSQL、SQLite、Redis、MongoDB、DuckDB、ClickHouse、SQL Server、Oracle、Elasticsearch,以及众多 MySQL/PG 兼容数据库
link: /zh-CN/guide/databases
linkText: 查看所有数据库
- icon: ✏️
title: 查询编辑器
details: CodeMirror 6 语法高亮、智能 SQL 补全(表名和字段)、格式化 SQL、执行选中文本
link: /zh-CN/guide/query-editor
linkText: 了解更多
- icon: 📊
title: 数据表格
details: 虚拟滚动表格,行内编辑、排序、搜索、WHERE 过滤、分页。编辑数据保存前预览 SQL
link: /zh-CN/guide/data-grid
linkText: 了解更多
- icon: 🤖
title: AI 助手
details: 自然语言生成 SQL、解释、优化、修复错误。支持 Claude、OpenAI 及兼容 API
link: /zh-CN/guide/ai-assistant
linkText: 了解更多
- icon: 🔌
title: MCP 集成
details: 让 Claude Code、Cursor 等 AI 编程助手直接查询数据库,还能在 DBX 中打开表
link: /zh-CN/guide/mcp
linkText: 配置指南
- icon: 🔄
title: Schema 对比与数据传输
details: 跨数据库对比 Schema 并生成同步 SQL。在不同数据库引擎之间传输数据
link: /zh-CN/guide/schema-diff
linkText: 了解更多
- icon: 🔍
title: 字段血缘
details: 通过外键、视图、查询历史和同名字段追踪列的依赖关系
link: /zh-CN/guide/field-lineage
linkText: 了解更多
- icon: 🔒
title: 安全与轻量
details: 密码存储在系统钥匙串,支持 SSH 隧道,加密配置导出。安装包约 15 MB,不内嵌 Chromium
link: /zh-CN/guide/config-export
linkText: 了解更多
---
<style>
.screenshot-section {
max-width: 1152px;
margin: 0 auto;
padding: 48px 24px;
}
.screenshot-section h2 {
text-align: center;
font-size: 1.5rem;
font-weight: 600;
margin-bottom: 24px;
}
.screenshot-section img {
width: 100%;
border-radius: 12px;
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.screenshot-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 16px;
margin-top: 16px;
}
.screenshot-grid img {
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
</style>
<div class="screenshot-section">
<h2>功能预览</h2>
<img src="/screenshot.png" alt="DBX 主界面" />
<div class="screenshot-grid">
<img src="/screenshot-connections.jpg" alt="连接对话框" />
<img src="/screenshot-ai.jpg" alt="AI 助手" />
</div>
</div>