94 lines
4.5 KiB
Markdown
94 lines
4.5 KiB
Markdown
# Database Query Tools — Self-Hosted REST API Options
|
|
|
|
Researched 2026-07-09. Source: detailed multi-step web research of 9 database-to-API tools.
|
|
|
|
## The Landscape
|
|
|
|
| Tool | Self-Hosted | Free | REST API | Raw SQL | MySQL | SQLite | Postgres | MCP | Setup |
|
|
|------|:-----------:|:----:|:--------:|:-------:|:----:|:------:|:--------:|:---:|:-----:|
|
|
| **Faucet** | ✅ | ✅ MIT | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ Native | <1 min |
|
|
| **Python Skill** | ✅ (in-process) | ✅ | N/A | ✅ | ✅ | ✅ | ✅ | ❌ | ~30 min |
|
|
| Directus | ✅ | ✅ MIT | ✅ | 🔶 Custom | ✅ | ❌ | ✅ | ❌ | ~30 min |
|
|
| Supabase | ✅ | ✅ (limited) | ✅ | ❌ (RPC only) | ❌ | ❌ | ✅ | ❌ | ~15 min |
|
|
| NocoDB | ✅ | 🔶 fair-code | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ~15 min |
|
|
| Adminer | ✅ | ✅ | ❌ None | ❌ | ✅ | ✅ | ✅ | ❌ | ~5 min |
|
|
| CloudBeaver | ✅ | 🔶 API paid | 🔶 Enterprise | 🔶 Enterprise | ✅ | ✅ | ✅ | 🔶 Enterprise | ~20 min |
|
|
| PostgREST | ✅ | ✅ MIT | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ~10 min |
|
|
| restSQL | ✅ | ✅ Apache | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ~30 min |
|
|
|
|
## 🏆 Top Pick: Faucet
|
|
|
|
- **MIT licensed, completely free** self-hosted. Cloud $5/mo Pro / $50/mo Team optional.
|
|
- **Single 47MB Go binary, zero dependencies.** No Docker, Node.js, PHP, or system DB needed.
|
|
- **All 3+ target databases:** MySQL 5.7+, SQLite 3.35+, PostgreSQL 9.6+ (also SQL Server, Oracle, Snowflake).
|
|
- **Auto-generates REST API** per table — CRUD + filtering + pagination + RBAC + OpenAPI docs.
|
|
- **Raw SQL via `faucet_raw_sql` MCP tool** — opt-in, disabled by default.
|
|
- **Native MCP server built in** — Hermes connects directly via mcp_servers config.
|
|
|
|
### Hermes Integration
|
|
|
|
**MCP server config in ~/.hermes/config.yaml:**
|
|
```yaml
|
|
mcp_servers:
|
|
database:
|
|
command: npx
|
|
args: ["@faucetdb/faucet", "serve", "--mcp"]
|
|
```
|
|
|
|
**Or run as standalone service then add DB connections:**
|
|
```bash
|
|
# Install (any method):
|
|
npx @faucetdb/faucet serve # npm
|
|
brew install faucetdb/tap/faucet # Homebrew
|
|
docker run -p 8080:8080 faucetdb/faucet:latest # Docker
|
|
|
|
# Add a database:
|
|
faucet db add --name mydb --driver postgres --dsn "postgres://user:pass@host/mydb"
|
|
|
|
# Create API key:
|
|
faucet key create --role default
|
|
|
|
# Query:
|
|
curl -H "X-Faucet-Api-Key: KEY" http://localhost:8080/api/v1/mydb/_table/users
|
|
```
|
|
|
|
**MCP tools available to Hermes:** faucet_list_services, faucet_list_tables, faucet_describe_table, faucet_query, faucet_insert, faucet_update, faucet_delete, faucet_raw_sql (disabled by default — enable explicitly).
|
|
|
|
## ⚠️ Raw SQL: The Critical Distinction
|
|
|
|
Many "database API" tools claim SQL support but actually require pre-registering queries as stored procedures (Supabase RPC, Directus custom endpoints) or defining SQL views (NocoDB). **Only Faucet and restSQL** offer ad-hoc raw SQL execution over the API.
|
|
|
|
**If ad-hoc SQL querying is needed** (the Hermes agent needs to explore unknown schemas, run arbitrary SELECTs, or debug production data), Faucet is the only actively maintained option that supports all 3 databases and raw SQL.
|
|
|
|
## 🥈 Fallback: Custom Python Skill
|
|
|
|
When you can't run an external service, write a Hermes skill with Python DB drivers:
|
|
|
|
```python
|
|
# ~/.hermes/skills/db-query/query.py
|
|
import sqlite3, mysql.connector, psycopg2, json, sys
|
|
|
|
def query_mysql(sql, params=None):
|
|
conn = mysql.connector.connect(host="wphost02", user=..., password=..., database=...)
|
|
cursor = conn.cursor(dictionary=True)
|
|
cursor.execute(sql, params or ())
|
|
return cursor.fetchall()
|
|
```
|
|
|
|
Hermes calls via: `python3 query.py --db mysql --query "SELECT * FROM users"`
|
|
|
|
**Pros:** Zero-infra, full control, works with any existing DB immediately.
|
|
**Cons:** Requires writing Python code, no automatic schema introspection, no RBAC layer.
|
|
|
|
## Research Methodology for Database Tools
|
|
|
|
When evaluating a database-to-API tool, check these axes in order:
|
|
|
|
1. **License** — MIT/Apache = safe. AGPL/fair-code/SSPL = legal risk for commercial.
|
|
2. **Single-binary vs stack** — fewer deps = less ops burden. Java runtimes are heavy.
|
|
3. **Databases supported** — must match your target set. Many are PostgreSQL-only.
|
|
4. **Raw SQL via API** — does it allow arbitrary queries, or only pre-defined CRUD on tables?
|
|
5. **MCP support** — native MCP is best (Hermes connects directly). REST + OpenAPI next.
|
|
6. **Active maintenance** — check GitHub: recent commits, release cadence, issue responsiveness.
|
|
7. **SaaS vs self-hosted paywall** — some are "open source" but API/MCP is enterprise-only (CloudBeaver).
|