Metadata-Version: 2.4
Name: db-mate
Version: 1.0.0
Summary: Database management toolkit - schema, query, migrate, backup
Author: EVOLVER
License-Expression: MIT
Project-URL: Repository, https://github.com/evolver-dev/db-mate
Keywords: database,sqlite,cli,db-tools
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# db-mate

A zero-dependency **SQLite database CLI manager** with color-coded output and an interactive TUI browser.

## Features

- **List tables** — view all tables with column names, types, and nullability
- **Schema visualization** — ASCII box-drawing of table schemas with DDL
- **Query execution** — run arbitrary SQL with nicely formatted table output
- **Export** — dump tables to CSV or JSON
- **Import** — load CSV files into tables
- **Statistics** — database file size, row counts, column type breakdowns, indexes
- **TUI mode** — curses-based interactive browser for tables and data
- **Zero external dependencies** — uses only Python stdlib (`sqlite3`, `csv`, `json`, `curses`)
- **Auto-detect** — finds `.db` files in the current directory

## Installation

```bash
cd /root/evolver-packages/db-mate
pip install -e .
```

## Usage

### CLI Mode

```bash
# List all tables in a database
db-mate list

# Show schema as ASCII diagram
db-mate schema

# Show tables with row counts
db-mate tables

# Run a SQL query
db-mate query "SELECT name, COUNT(*) FROM users GROUP BY name"

# Export a table
db-mate export users csv
db-mate export users json

# Import a CSV into a table
db-mate import users data.csv

# Show database statistics
db-mate stats

# Specify a database explicitly
db-mate --db mydata.db list
db-mate --db mydata.db query "SELECT * FROM users"
```

### TUI Mode

```bash
# Launch the interactive curses-based browser
db-mate --tui

# With a specific database
db-mate --db mydata.db --tui
```

### TUI Key Bindings

| Key | Action |
|-----|--------|
| `t` | Tables overview |
| `b` | Browse table data |
| `s` | SQL query mode |
| `n` / `p` | Next / previous table |
| `j` / `k` | Scroll down / up |
| `←` / `→` | Scroll columns (browse mode) |
| `Enter` | Execute SQL query |
| `q` | Quit |

## Examples

```bash
# Create a test database and explore it
$ sqlite3 test.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT);"
$ sqlite3 test.db "INSERT INTO users VALUES (1, 'Alice', 'alice@example.com'), (2, 'Bob', 'bob@example.com');"

$ db-mate --db test.db list
$ db-mate --db test.db schema
$ db-mate --db test.db stats
$ db-mate --db test.db query "SELECT * FROM users"
```

## Project Structure

```
db-mate/
├── pyproject.toml
├── README.md
└── src/
    └── db_mate/
        ├── __init__.py
        ├── __main__.py
        ├── cli.py
        └── tui.py
```

## License

MIT
