Skip to content

RiskyMH/dbcat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dbcat

A simple CLI to view database tables. Supports PostgreSQL, MySQL, and SQLite.

bunx dbcat ./data.db

Usage

Connect to a database to browse all tables:

# No argument - uses DATABASE_URL environment variable
bunx dbcat

# SQLite
bunx dbcat ./database.sqlite
bunx dbcat https://example.com/data.db

# PostgreSQL
bunx dbcat postgres://user:pass@localhost:5432/mydb

# MySQL
bunx dbcat mysql://user:pass@localhost:3306/mydb

Run a query by piping SQL:

echo "SELECT * FROM users" | bunx dbcat ./data.db

Options

Flag Description
--full, -f Show all rows & data when browsing tables (default: 100 rows)
--json Output as JSON (indented if TTY)
--json=color Output as normal object console.log

Piped queries always return all rows.

Example

$ bunx dbcat ./demo.sqlite
Connected to demo.sqlite

╭─ users ────────────┬───────────────────┬─────────────────────╮
│ id │ name          │ email             │ created_at          │
├────┼───────────────┼───────────────────┼─────────────────────┤
│  1 │ Alice Johnson │ [email protected] │ 2025-12-08 05:25:21 │
│  2 │ Bob Smith     │ [email protected]   │ 2025-12-08 05:25:21 │
│  3 │ Carol White   │ [email protected] │ 2025-12-08 05:25:21 │
│ ... 47 more rows                                             │
╰──────────────────────────────────────────────────────────────╯

Scrollable Output

Pipe to less -R for scrollable output with colors:

bunx dbcat ./data.db --full | less -R

Git diffable

Do these things to make git use dbcat to diff your sqlite databases:

# .gitattributes
*.sqlite binary diff=dbcat
*.db binary diff=dbcat
git config diff.lockb.textconv "bunx dbcat --full"
git config diff.lockb.binary true

And now you should be able to use

git diff ./data.db

Requirements

Bun v1.3+

About

A simple CLI to view database tables. Supports PostgreSQL, MySQL, and SQLite (because it uses `Bun.sql`).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors