https://github.com/riskymh/dbcat
A simple CLI to view database tables. Supports PostgreSQL, MySQL, and SQLite (because it uses `Bun.sql`).
https://github.com/riskymh/dbcat
bun cli database mysql postgres sql sqlite tui
Last synced: about 1 month ago
JSON representation
A simple CLI to view database tables. Supports PostgreSQL, MySQL, and SQLite (because it uses `Bun.sql`).
- Host: GitHub
- URL: https://github.com/riskymh/dbcat
- Owner: RiskyMH
- Created: 2025-12-08T08:17:47.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-12-10T17:51:42.000Z (about 2 months ago)
- Last Synced: 2025-12-11T04:14:10.983Z (about 2 months ago)
- Topics: bun, cli, database, mysql, postgres, sql, sqlite, tui
- Language: TypeScript
- Homepage: https://npm.im/dbcat
- Size: 26.4 KB
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `dbcat`
A simple CLI to view database tables. Supports PostgreSQL, MySQL, and SQLite.
```sh
bunx dbcat ./data.db
```
## Usage
Connect to a database to browse all tables:
```sh
# 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:
```sh
echo "SELECT * FROM users" | bunx dbcat ./data.db
```
### Options
| Flag | Description |
|----------------|---------------------------------------------------|
| `--full`, `-f` | Show all rows when browsing tables (default: 100) |
| `--json` | Output as JSON (indented if TTY) |
| `--json=color` | Output as normal object console.log |
Piped queries always return all rows.
## Example
```sh
$ bunx dbcat ./demo.sqlite
Connected to demo.sqlite
╭─ users ────────────┬───────────────────┬─────────────────────╮
│ id │ name │ email │ created_at │
├────┼───────────────┼───────────────────┼─────────────────────┤
│ 1 │ Alice Johnson │ alice@example.com │ 2025-12-08 05:25:21 │
│ 2 │ Bob Smith │ bob@example.com │ 2025-12-08 05:25:21 │
│ 3 │ Carol White │ carol@example.com │ 2025-12-08 05:25:21 │
│ ... 47 more rows │
╰──────────────────────────────────────────────────────────────╯
```
### Scrollable Output
Pipe to `less -R` for scrollable output with colors:
```sh
bunx dbcat ./data.db --full | less -R
```
### Git diffable
Do these things to make git use `dbcat` to diff your sqlite databases:
```sh
# .gitattributes
*.sqlite binary diff=dbcat
*.db binary diff=dbcat
```
```sh
git config diff.lockb.textconv "bunx dbcat --full"
git config diff.lockb.binary true
```
And now you should be able to use
```sh
git diff ./data.db
```
## Requirements
[Bun](https://bun.sh) v1.3+