Automatic database row snapshots before DML execution. A transaction-like rollback mechanism for PostgreSQL testing and debugging.
dbsnap runs as a wire protocol proxy between your application and PostgreSQL. It transparently intercepts DML queries (INSERT, UPDATE, DELETE), snapshots affected rows, and provides undo capability through a terminal UI.
Your App (:5433) → dbsnap (proxy) → PostgreSQL (:5432)
| Original Query | Undo Action |
|---|---|
INSERT |
Deletes the inserted rows |
UPDATE |
Restores rows to their previous values |
DELETE |
Re-inserts the deleted rows |
# Start dbsnap proxy + TUI (defaults to localhost:5432)
dbsnap
# Or specify a custom PostgreSQL address
dbsnap --pg myhost:5432
# Custom proxy listen port
dbsnap --listen :5433 --pg myhost:5432
# Point your app at the proxy instead of PostgreSQL directly
DATABASE_URL="postgres://user:pass@localhost:5433/mydb"The proxy automatically detects the user and database from the client's connection — no need to specify a full connection string.
| Key | Action |
|---|---|
↑/↓ |
Navigate history |
u |
Undo selected query |
tab |
Switch panels |
q |
Quit |
- Go — core language
- Bubble Tea — terminal UI framework
- pg_query_go — PostgreSQL SQL parser
- pgx — PostgreSQL driver
MIT