sqlite-query

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SQLite Query via MCP

基于MCP的SQLite查询

Use this skill when you need to query SQLite databases, inspect schemas, or optimize queries. Read-only by default for safety.
当你需要查询SQLite数据库、检查模式或优化查询时使用此技能。为保障安全,默认启用只读模式。

Available Tools

可用工具

ToolWhat it does
query
Execute SQL (SELECT, PRAGMA, EXPLAIN, WITH). Returns results as a table.
schema
Full schema: all tables with columns, types, and row counts
table_info
Detailed info for a single table: columns, constraints, row count
explain
Run EXPLAIN QUERY PLAN for query optimization
list_databases
List .db, .sqlite, .sqlite3 files in a directory
工具功能说明
query
执行SQL(SELECT、PRAGMA、EXPLAIN、WITH),以表格形式返回结果。
schema
返回完整模式:所有表的列、数据类型和行数
table_info
单个表的详细信息:列、约束、行数
explain
执行EXPLAIN QUERY PLAN用于查询优化
list_databases
列出指定目录下的.db、.sqlite、.sqlite3文件

Workflow

工作流程

  1. list_databases
    to find .db files in the project
  2. schema
    to understand the full database structure
  3. table_info
    for detailed column info on specific tables
  4. query
    to run SELECT queries and inspect data
  5. explain
    to optimize slow queries
  1. 执行
    list_databases
    查找项目中的.db文件
  2. 执行
    schema
    了解完整的数据库结构
  3. 执行
    table_info
    获取指定表的详细列信息
  4. 执行
    query
    运行SELECT查询并检查数据
  5. 执行
    explain
    优化慢查询

Key Patterns

核心要点

  • Read-only by default — only SELECT, PRAGMA, EXPLAIN, and WITH are allowed
  • Pass
    readonly: false
    in tool args to enable INSERT, UPDATE, DELETE
  • schema
    returns everything at once — use it first to understand the database
  • query
    returns tabular results — ideal for exploration and debugging
  • Database path is passed per-tool call, not globally configured
  • 默认只读 —— 仅允许执行SELECT、PRAGMA、EXPLAIN和WITH语句
  • 如需启用INSERT、UPDATE、DELETE,可在工具参数中传入
    readonly: false
  • schema
    会一次性返回所有信息 —— 建议优先使用它来了解数据库情况
  • query
    返回表格化结果 —— 非常适合数据探索和调试
  • 数据库路径随每次工具调用传入,无需全局配置

Safety

安全说明

  • Read-only mode is on by default — no accidental mutations
  • Confirm with the user before enabling write mode (
    readonly: false
    )
  • Large result sets are truncated — use LIMIT in queries for efficiency
  • 默认启用只读模式 —— 不会发生意外的数据变更
  • 启用写入模式(
    readonly: false
    )前请先征得用户同意
  • 大型结果集会被截断 —— 建议在查询中使用LIMIT提升查询效率