Skip to main content

Database management toolkit - schema, query, migrate, backup

Project description

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

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

Usage

CLI Mode

# 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

# 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

# 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

db_mate-1.0.0-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file db_mate-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: db_mate-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for db_mate-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c42fc94fed2a01f043590258ec0363ac30391929f0ab56fdb9b25ba6a8083f63
MD5 ac44d04f9839c9e478fb051bb9bd6306
BLAKE2b-256 95534681afab41832cdca040038c08a7695aaaae1b71644e18b5812425f0f626

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page