← 返回 Skills 市场
wu-uk

sqlite-map-parser

作者 wu-uk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ 安全检测通过
83
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install civ6-adjacency-optimizer-sqlite-map-parser
功能描述
Parse SQLite databases into structured JSON data. Use when exploring unknown database schemas, understanding table relationships, and extracting map data as...
使用说明 (SKILL.md)

SQLite to Structured JSON

Parse SQLite databases by exploring schemas first, then extracting data into structured JSON.

Step 1: Explore the Schema

Always start by understanding what tables exist and their structure.

List All Tables

SELECT name FROM sqlite_master WHERE type='table';

Inspect Table Schema

-- Get column names and types
PRAGMA table_info(TableName);

-- See CREATE statement
SELECT sql FROM sqlite_master WHERE name='TableName';

Find Primary/Unique Keys

-- Primary key info
PRAGMA table_info(TableName);  -- 'pk' column shows primary key order

-- All indexes (includes unique constraints)
PRAGMA index_list(TableName);

-- Columns in an index
PRAGMA index_info(index_name);

Step 2: Understand Relationships

Identify Foreign Keys

PRAGMA foreign_key_list(TableName);

Common Patterns

ID-based joins: Tables often share an ID column

-- Main table has ID as primary key
-- Related tables reference it
SELECT m.*, r.ExtraData
FROM MainTable m
LEFT JOIN RelatedTable r ON m.ID = r.ID;

Coordinate-based keys: Spatial data often uses computed coordinates

# If ID represents a linear index into a grid:
x = id % width
y = id // width

Step 3: Extract and Transform

Basic Pattern

import sqlite3
import json

def parse_sqlite_to_json(db_path):
    conn = sqlite3.connect(db_path)
    conn.row_factory = sqlite3.Row  # Access columns by name
    cursor = conn.cursor()

    # 1. Explore schema
    cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
    tables = [row[0] for row in cursor.fetchall()]

    # 2. Get dimensions/metadata from config table
    cursor.execute("SELECT * FROM MetadataTable LIMIT 1")
    metadata = dict(cursor.fetchone())

    # 3. Build indexed data structure
    data = {}
    cursor.execute("SELECT * FROM MainTable")
    for row in cursor.fetchall():
        key = row["ID"]  # or compute: (row["X"], row["Y"])
        data[key] = dict(row)

    # 4. Join related data
    cursor.execute("SELECT * FROM RelatedTable")
    for row in cursor.fetchall():
        key = row["ID"]
        if key in data:
            data[key]["extra_field"] = row["Value"]

    conn.close()
    return {"metadata": metadata, "items": list(data.values())}

Handle Missing Tables Gracefully

def safe_query(cursor, query):
    try:
        cursor.execute(query)
        return cursor.fetchall()
    except sqlite3.OperationalError:
        return []  # Table doesn't exist

Step 4: Output as Structured JSON

Map/Dictionary Output

Use when items have natural unique keys:

{
  "metadata": {"width": 44, "height": 26},
  "tiles": {
    "0,0": {"terrain": "GRASS", "feature": null},
    "1,0": {"terrain": "PLAINS", "feature": "FOREST"},
    "2,0": {"terrain": "COAST", "resource": "FISH"}
  }
}

Array Output

Use when order matters or keys are simple integers:

{
  "metadata": {"width": 44, "height": 26},
  "tiles": [
    {"x": 0, "y": 0, "terrain": "GRASS"},
    {"x": 1, "y": 0, "terrain": "PLAINS", "feature": "FOREST"},
    {"x": 2, "y": 0, "terrain": "COAST", "resource": "FISH"}
  ]
}

Common Schema Patterns

Grid/Map Data

  • Main table: positions with base properties
  • Feature tables: join on position ID for overlays
  • Compute (x, y) from linear ID: x = id % width, y = id // width

Hierarchical Data

  • Parent table with primary key
  • Child tables with foreign key reference
  • Use LEFT JOIN to preserve all parents

Enum/Lookup Tables

  • Type tables map codes to descriptions
  • Join to get human-readable values

Debugging Tips

-- Sample data from any table
SELECT * FROM TableName LIMIT 5;

-- Count rows
SELECT COUNT(*) FROM TableName;

-- Find distinct values in a column
SELECT DISTINCT ColumnName FROM TableName;

-- Check for nulls
SELECT COUNT(*) FROM TableName WHERE ColumnName IS NULL;
安全使用建议
This skill is a coherent, instruction-only guide for parsing SQLite files to JSON and does not require secrets or installs. However, be cautious about which database files you give an agent access to: SQLite files can contain sensitive personal or application data. Ensure the runtime environment has Python and sqlite3 available if you plan to run the provided examples, and restrict the agent's file-access permissions so it cannot open arbitrary system or application databases. If you need stricter guarantees, review any concrete code you copy from the SKILL.md before running it.
功能分析
Type: OpenClaw Skill Name: civ6-adjacency-optimizer-sqlite-map-parser Version: 0.1.0 The skill bundle provides standard SQL and Python templates for exploring and parsing SQLite databases into JSON format, specifically tailored for grid-based map data. There are no signs of malicious intent, data exfiltration, or prompt injection; the code uses the standard 'sqlite3' library and follows common database inspection patterns (SKILL.md).
能力评估
Purpose & Capability
Name/description match the content: SKILL.md contains SQL and Python examples for exploring SQLite schemas and exporting data to JSON. It requests no unrelated credentials, binaries, or config paths.
Instruction Scope
Instructions are narrowly scoped to querying SQLite (PRAGMA/sql SELECT) and transforming results to JSON; they reference only a db_path and generic table names. There is no guidance to read unrelated files, environment variables, or send data to external endpoints.
Install Mechanism
No install spec or external downloads are present; this is instruction-only so nothing is written to disk by the skill itself.
Credentials
The skill declares no environment variables, credentials, or special config paths and the examples only use the local sqlite3 Python library and a provided DB path — proportionate to the stated function.
Persistence & Privilege
always is false and the skill does not request persistent or cross-skill configuration or elevated privileges. Autonomous invocation is allowed by default but not requested to be forced.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install civ6-adjacency-optimizer-sqlite-map-parser
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /civ6-adjacency-optimizer-sqlite-map-parser 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v0.1.0
Bulk publish from all-task-skills-dedup
元数据
Slug civ6-adjacency-optimizer-sqlite-map-parser
版本 0.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

sqlite-map-parser 是什么?

Parse SQLite databases into structured JSON data. Use when exploring unknown database schemas, understanding table relationships, and extracting map data as... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 83 次。

如何安装 sqlite-map-parser?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install civ6-adjacency-optimizer-sqlite-map-parser」即可一键安装,无需额外配置。

sqlite-map-parser 是免费的吗?

是的,sqlite-map-parser 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

sqlite-map-parser 支持哪些平台?

sqlite-map-parser 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 sqlite-map-parser?

由 wu-uk(@wu-uk)开发并维护,当前版本 v0.1.0。

💬 留言讨论