explore-db
aahl-byte/explore-db
a simple CLI to query read-only instances of a postgresql database - the intention is to give an agent read-only access to the database without an MCP server - simply execute `explore-db --help` to learn how to use the CLI
Instalação
npx convez-ai aahl-byte/explore-db1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.
Métricas
README
A tradução para o português deste README ainda está na fila.
explore-db
A CLI tool for running read-only SQL queries against PostgreSQL databases across multiple environments (dev, staging, production).
Connections are enforced as read-only via default_transaction_read_only=on, so you can safely explore without risk of accidental writes.
Installation
Requires Python 3.9+.
pip install git+https://github.com/aahl-byte/explore-db
Or for development:
git clone https://github.com/aahl-byte/explore-db.git && pip install -e explore-db
Setup
On first run, explore-db creates a default config directory at ~/.explore-db/ containing:
| File | Purpose |
|---|---|
config.json | Maps environment names to .env files (or direct connection strings) |
.env.dev | Dev database connection |
.env.staging | Staging database connection |
.env.production | Production database connection |
To initialize manually:
explore-db --dev "SELECT 1"
Then edit the generated files to set your actual connection strings.
Config format
~/.explore-db/config.json maps each environment to either a .env filename or a direct PostgreSQL URL:
{
"dev": ".env.dev",
"staging": ".env.staging",
"production": "postgresql://user:password@host:5432/dbname"
}
Each .env file should contain a DATABASE_URL variable:
DATABASE_URL=postgresql://user:password@host:5432/dbname
Usage
Pick an environment with --dev, --staging, or --production, then provide SQL in one of three ways:
Inline query:
explore-db --dev "SELECT * FROM users LIMIT 10"
From a file:
explore-db --staging -f query.sql
Piped from stdin:
cat query.sql | explore-db --production
Output
Results are printed as JSON with column names and row count:
Columns: ['id', 'name', 'email']
Row count: 2
[
{
"id": 1,
"name": "Alice",
"email": "alice@example.com"
},
{
"id": 2,
"name": "Bob",
"email": "bob@example.com"
}
]