SQLite Interactive Shell
Open an interactive SQLite shell to query and inspect the database directly.
Open Shell
bash
make sqlite-shell
This opens the SQLite CLI connected to ./data/budget.db
Common Queries
View all tables
sql
.tables
View table schema
sql
.schema users .schema transactions .schema budgets
Query data
sql
SELECT * FROM users LIMIT 10; SELECT COUNT(*) FROM transactions; SELECT * FROM budgets WHERE status = 'active';
View database statistics
Exit the shell and run:
bash
make sqlite-stats
Shows:
- •Database file size
- •Number of tables
- •Row counts per table
- •Index information
Useful SQLite Commands
- •
.help- Show all available commands - •
.exitor.quit- Exit the shell - •
.mode- Change output format (column, csv, json, etc.) - •
.headers on- Show column headers - •
.schema- Show all table schemas - •
.dump [table]- Export table as SQL - •
.read file.sql- Execute SQL from file
Safety Tips
- •Read-only queries: Use SELECT for inspection
- •Backup first: Run
/db-backupbefore any modifications - •Test in dev: Never experiment on production database
- •Use transactions: Wrap modifications in BEGIN/COMMIT
Example Session
sql
-- Connect to database sqlite> .tables -- View users sqlite> SELECT id, email, role FROM users; -- Count transactions by type sqlite> SELECT type, COUNT(*) FROM transactions GROUP BY type; -- Check budget status sqlite> SELECT name, amount, spent FROM budgets ORDER BY created_at DESC LIMIT 5; -- Exit sqlite> .exit
See Also
- •
/db-backup- Create database backup - •
make sqlite-stats- View database statistics - •
make migrate-create- Create new migration