whodb

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

WhoDB Database Assistant

WhoDB 数据库助手

You have access to WhoDB for database operations. Use these tools and commands to help users with database tasks.
你可以使用WhoDB进行数据库操作。使用以下工具和命令来帮助用户完成数据库任务。

MCP Tools (Preferred)

MCP 工具(优先选择)

When the WhoDB MCP server is available, use these tools directly:
当WhoDB MCP服务器可用时,请直接使用以下工具:

whodb_connections

whodb_connections

List all available database connections.
No parameters required.
Returns: List of connection names with type and source (env/saved).
列出所有可用的数据库连接。
No parameters required.
Returns: List of connection names with type and source (env/saved).

whodb_query

whodb_query

Execute SQL queries against a database.
Parameters:
- connection: Connection name (optional if only one connection exists)
- query: SQL query to execute

Example: whodb_query(connection="mydb", query="SELECT * FROM users LIMIT 10")
对数据库执行SQL查询。
Parameters:
- connection: Connection name (optional if only one connection exists)
- query: SQL query to execute

Example: whodb_query(connection="mydb", query="SELECT * FROM users LIMIT 10")

whodb_schemas

whodb_schemas

List all schemas in a database.
Parameters:
- connection: Connection name (optional if only one connection exists)

Example: whodb_schemas(connection="mydb")
列出数据库中的所有架构。
Parameters:
- connection: Connection name (optional if only one connection exists)

Example: whodb_schemas(connection="mydb")

whodb_tables

whodb_tables

List all tables in a schema.
Parameters:
- connection: Connection name (optional if only one connection exists)
- schema: Schema name (optional, uses default if not specified)

Example: whodb_tables(connection="mydb", schema="public")
列出架构中的所有表。
Parameters:
- connection: Connection name (optional if only one connection exists)
- schema: Schema name (optional, uses default if not specified)

Example: whodb_tables(connection="mydb", schema="public")

whodb_columns

whodb_columns

Describe columns in a table.
Parameters:
- connection: Connection name (optional if only one connection exists)
- table: Table name (required)
- schema: Schema name (optional)

Example: whodb_columns(connection="mydb", table="users")
描述表中的列信息。
Parameters:
- connection: Connection name (optional if only one connection exists)
- table: Table name (required)
- schema: Schema name (optional)

Example: whodb_columns(connection="mydb", table="users")

CLI Commands (Fallback)

CLI 命令(备选方案)

If MCP tools are unavailable, use the CLI directly via Bash:
如果MCP工具不可用,请通过Bash直接使用CLI:

Query Execution

查询执行

bash
whodb-cli query "SELECT * FROM users LIMIT 10" --connection mydb --format json
bash
whodb-cli query "SELECT * FROM users LIMIT 10" --connection mydb --format json

Schema Discovery

架构发现

bash
undefined
bash
undefined

List schemas

List schemas

whodb-cli schemas --connection mydb --format json
whodb-cli schemas --connection mydb --format json

List tables

List tables

whodb-cli tables --connection mydb --schema public --format json
whodb-cli tables --connection mydb --schema public --format json

Describe columns

Describe columns

whodb-cli columns --connection mydb --table users --format json
undefined
whodb-cli columns --connection mydb --table users --format json
undefined

Connection Management

连接管理

bash
undefined
bash
undefined

List connections

List connections

whodb-cli connections list --format json
whodb-cli connections list --format json

Test connection

Test connection

whodb-cli connections test mydb
whodb-cli connections test mydb

Add new connection (interactive)

Add new connection (interactive)

whodb-cli connections add --name mydb --type Postgres --host localhost --database mydb
undefined
whodb-cli connections add --name mydb --type Postgres --host localhost --database mydb
undefined

Data Export

数据导出

bash
undefined
bash
undefined

Export to CSV

Export to CSV

whodb-cli export --connection mydb --table users --output users.csv
whodb-cli export --connection mydb --table users --output users.csv

Export query results

Export query results

whodb-cli export --connection mydb --query "SELECT * FROM orders" --output orders.xlsx
undefined
whodb-cli export --connection mydb --query "SELECT * FROM orders" --output orders.xlsx
undefined

Workflow Examples

工作流示例

Explore a New Database

探索新数据库

  1. List connections:
    whodb_connections
  2. List schemas:
    whodb_schemas(connection="name")
  3. List tables:
    whodb_tables(connection="name", schema="public")
  4. Describe table:
    whodb_columns(connection="name", table="users")
  5. Sample data:
    whodb_query(connection="name", query="SELECT * FROM users LIMIT 5")
  1. 列出连接:
    whodb_connections
  2. 列出架构:
    whodb_schemas(connection="name")
  3. 列出表:
    whodb_tables(connection="name", schema="public")
  4. 描述表:
    whodb_columns(connection="name", table="users")
  5. 示例数据:
    whodb_query(connection="name", query="SELECT * FROM users LIMIT 5")

Answer Data Questions

回答数据相关问题

  1. Understand the schema first - check table structure
  2. Write targeted queries with appropriate filters
  3. Always use LIMIT for exploratory queries
  4. Present results in a clear, readable format
  1. 首先了解架构 - 检查表结构
  2. 编写带有适当筛选条件的针对性查询
  3. 探索性查询始终使用LIMIT
  4. 以清晰、易读的格式呈现结果

Best Practices

最佳实践

  • Always explore schema first before writing queries
  • Use LIMIT for exploratory queries to avoid overwhelming output
  • Prefer specific columns over SELECT * for clarity
  • Check foreign keys via whodb_columns to understand relationships
  • Use JSON format (--format json) when parsing output programmatically
  • Never expose credentials - use connection names, not connection strings
  • 始终先探索架构再编写查询
  • 使用LIMIT进行探索性查询,避免输出过多
  • 优先选择特定列而非SELECT *,以提高清晰度
  • 通过whodb_columns检查外键来理解表之间的关系
  • 编程解析输出时使用JSON格式(--format json)
  • 切勿暴露凭证 - 使用连接名称,而非连接字符串