---
name: sqlite
displayName: SQLite Reader & Converter
description: Reads and converts SQLite database files (.db .sqlite .sqlite3) to
  text, JSON, or CSV. Use when inspecting or extracting data from a SQLite
  single-file database.
tags:
  - sqlite
  - database
  - extractor
  - csv
  - json
  - converter
capabilities:
  - ReadSqlite
  - ConvertToCsv
  - ConvertToJson
  - DumpSchema
  - QueryTable
  - SchemaDiff
representativeQueries:
  - read a .db file and show me what's inside
  - convert sqlite to CSV
  - extract data from a sqlite3 database file
  - what tables are in this .sqlite file
  - compare the schema of two sqlite databases and show what changed
version: 0.1.0
tier: curated
---

# SQLite Reader & Converter

Reads SQLite single-file databases (.db, .sqlite, .sqlite3) and converts their contents to human-readable text, JSON, or CSV using Python's built-in `sqlite3` module — no external dependencies required.

## When to use

- Inspect an unfamiliar `.db`, `.sqlite`, or `.sqlite3` file to understand its schema and contents.
- Extract one or more tables as CSV or JSON for downstream processing.
- Confirm a database's structure before writing or migrating data.
- Detect well-known application schemas (browsers, password managers, mobile backups).

## Steps

1. **Locate and verify the source file.** Confirm the file exists and starts with the SQLite magic bytes (`SQLite format 3\000`). Reject non-SQLite files early with a clear error.
2. **Open read-only.** Connect via `sqlite3.connect("file:<path>?mode=ro", uri=True)` to prevent accidental writes.
3. **Enumerate objects.** Query `sqlite_master` for tables and views; log the schema SQL for reference.
4. **Extract and convert.** For each table: fetch all rows with `SELECT * FROM <table>`, map column names from `cursor.description`, and write to the requested output format (text summary, CSV via `csv.writer`, or JSON via `json.dumps`).
5. **Handle edge cases.** Hex-encode BLOB values, skip SQLite internal tables (`sqlite_*` prefix) and virtual-table shadow tables (e.g. FTS5 `<vtab>_data`, `<vtab>_content`), and surface WAL-mode warnings if sidecar files are missing.

## Output

- **Text summary** (default): schema overview followed by paginated row samples.
- **CSV**: all tables written to stdout; single-table output is RFC 4180 compliant with header row. Multi-table output separates tables with blank lines and `# table: <name>` comment lines (not RFC 4180 compliant; pipe to `grep -v '^#'` to strip).
- **JSON**: array of objects keyed by column name, UTF-8 encoded, BLOBs as hex strings.

## Notes

- The `scripts/sqlite_converter.py` script accepts `--format text|csv|json`, `--table <name>` to target a single table, and `--limit N` to cap row output.
- WAL sidecar files (`.db-wal`, `.db-shm`) must reside alongside the main file; missing sidecars mean the WAL is not included.
- Very large BLOBs (e.g., cached images in browser databases) produce verbose hex output — use `--skip-blobs` to omit them.
- For read-only queries beyond simple table dumps, run arbitrary SQL with the `--query` flag (SELECT only; DML is blocked by the read-only URI mode).

<!-- runner-fallback -->
## Remote runner (MCP)
Can't run this locally (no setup, missing dependency)? The StealthStack runner exposes the **same code** as server-side MCP tools — no local install needed: `sqlite_read`, `sqlite_query`, `sqlite_schema_diff`. Call the `application/mcp` catalog twin of this skill (its `runnerTwin`).
