# Database Scout

Explore SQLite and PostgreSQL databases: list tables, inspect schemas...

- Repository: https://github.com/zebbern/claude-code-guide (4691 stars)
- Category: Data and ML
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add zebbern/claude-code-guide --skill database-scout -g -a claude-code -y`
Codex: `npx skills add zebbern/claude-code-guide --skill database-scout -g -a codex -y`
Cursor: `npx skills add zebbern/claude-code-guide --skill database-scout -g -a cursor -y`
Gemini CLI: `npx skills add zebbern/claude-code-guide --skill database-scout -g -a gemini-cli -y`

## Description

Explore SQLite and PostgreSQL databases: list tables, inspect schemas (columns/types/constraints), preview data, generate Mermaid ER diagrams, and run safe read-only queries. Triggered by requests to explore a database, view table structures, describe tables, generate diagrams, or query data, and by keywords like database exploration, schema, ER diagram, or SQL query.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# database-scout

Read-only exploration tool for SQLite / PostgreSQL databases, inspect table schemas, preview data, generate ER diagrams, and run safe queries.

## Feature Overview

| Feature | Description |
|---------|-------------|
| List all tables | Show tables and views in the database, with row counts |
| Inspect table schema | Column names, types, constraints (PK/FK/NOT NULL), indexes, defaults |
| Data preview | View the first N rows of a table |
| ER diagram generation | Output Mermaid erDiagram syntax, ready to render |
| Safe read-only queries | Only SELECT/WITH/EXPLAIN allowed; write operations are blocked |

## Security Mechanisms

- **Connection-level read-only**: SQLite opens with `?mode=ro` URI; PostgreSQL uses `SET SESSION READ ONLY`
- **SQL whitelist**: Only statements starting with SELECT / WITH / EXPLAIN / PRAGMA / SHOW are allowed
- **Dangerous keyword blocking**: INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, and 30+ other keywords are blocked
- **Multi-statement blocking**: Semicolon-separated multiple SQL statements are rejected (prevents injection)
- **Identifier escaping**: Table names are double-quote escaped to prevent SQL injection

## Quick Start

```bash
# List all tables in a SQLite database
python3 scripts/db_explorer.py --db-path data.db list-tables

# Inspect table schema
python3 scripts/db_explorer.py --db-path data.db describe users

# Preview data (default 20 rows)
python3 scripts/db_explorer.py --db-path data.db preview orders --limit 10

# Generate Mermaid ER diagram
python3 scripts/db_explorer.py --db-path data.db er-diagram

# Run a read-only query
python3 scripts/db_explorer.py --db-path data.db query "SELECT name, age FROM users WHERE age > 18 LIMIT 10"
```

### PostgreSQL

```bash
# Connect to PostgreSQL
python3 scripts/db_explorer.py --db-type postgres --dsn "host=localhost dbname=mydb user=reader" list-tables

The rest: https://github.com/zebbern/claude-code-guide/blob/HEAD/skills/database-scout/SKILL.md
