| Crates.io | sqlk |
| lib.rs | sqlk |
| version | 0.1.5 |
| created_at | 2025-09-01 21:31:07.927558+00 |
| updated_at | 2025-09-03 07:19:30.265438+00 |
| description | A terminal-based PostgreSQL query execution and visualization tool with vim-like navigation. |
| homepage | |
| repository | https://github.com/sethrollinsbah/sqlk |
| max_upload_size | |
| id | 1820287 |
| size | 265,645 |

A terminal-based SQL query execution and visualization tool with vim-like navigation and Matrix-style loading animations.
git clone https://github.com/SethRollinsBah/SQLk.git
cd sqlk
cargo build --release
The binary will be available at target/release/sqlk.
# Execute with a SQL file
sqlk --file queries.sql
# Use a custom .env file
sqlk --env .env.development --file queries.sql
# Execute a specific query
sqlk --query "SELECT * FROM users LIMIT 10"
# Combine file and environment
sqlk --env .env.production --file analytics.sql
Create a .env file in your project directory:
DATABASE_URL="postgresql://username:password@localhost:5432/database_name"
SQLK uses a configuration file located at:
~/.config/sqlk/config.toml%APPDATA%\sqlk\config.tomlExample configuration:
env_file = ".env"
[matrix]
enabled = true
duration_ms = 6000
chars = "ハミヒーウシナモニサワツオリアホテマケメエカキムユラセネスタヌヘ01"
width = 80
height = 24
[foreign_keys]
enabled = true
[foreign_keys.manual_mapping]
user_id = "users.id"
product_id = "products.id"
[database]
url = "postgresql://localhost:5432/mydb"
db_type = "PostgreSQL" # optional, SQLk finds database from string
| Key | Action |
|---|---|
j/k or ↓/↑ |
Navigate lines |
PageUp/PageDown |
Page navigation |
Home/End |
Jump to start/end |
e |
Execute query at cursor |
? |
Show help |
q or Esc |
Quit |
| Key | Action |
|---|---|
h/j/k/l or Arrow keys |
Navigate cells |
yy |
Copy entire row |
yiw |
Copy current cell |
/ |
Search in results |
F |
Foreign key lookup |
c |
Chart mode |
K |
Show cell info |
? |
Show help |
q or Esc |
Back to file view |
| Key | Action |
|---|---|
Enter |
Execute search |
Esc |
Cancel search |
Backspace |
Delete character |
SQLK can parse and execute SQL query blocks from files. Queries can be separated by:
-- or /* */)Example file:
-- User analytics query
SELECT
u.id,
u.email,
COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id, u.email
ORDER BY order_count DESC
LIMIT 20;
-- Product performance
SELECT
p.name,
SUM(oi.quantity) as total_sold,
SUM(oi.price * oi.quantity) as revenue
FROM products p
JOIN order_items oi ON p.id = oi.product_id
WHERE oi.created_at > NOW() - INTERVAL '30 days'
GROUP BY p.id, p.name
ORDER BY revenue DESC;
SQLK automatically detects foreign key relationships in PostgreSQL databases. When viewing query results:
F to lookup related recordsK to view detailed cell information including foreign key relationshipsYou can define custom foreign key relationships in your config:
[foreign_keys.manual_mapping]
user_id = "users.id"
customer_id = "customers.id"
order_id = "orders.id"
src/
├── main.rs # Application entry point
├── app/ # Main application logic
│ ├── mod.rs
│ ├── state.rs # Application state management
│ ├── events.rs # Event loop and updates
│ ├── modes.rs # Mode-specific handlers
│ └── input.rs # Input processing
├── database/ # Database abstraction layer
│ ├── mod.rs
│ ├── manager.rs # Database manager trait
│ └── postgres/ # PostgreSQL implementation
├── config/ # Configuration management
│ ├── mod.rs
│ ├── types.rs # Config structures
│ ├── loader.rs # File loading
│ └── parser.rs # URL parsing
├── ui/ # User interface
├── table_viewer/ # Table display logic
└── matrix/ # Matrix animation
# Development build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with logging
RUST_LOG=debug cargo run -- --file test.sql
sqlx - Async SQL toolkittokio - Async runtimeratatui - Terminal UI frameworkcrossterm - Cross-platform terminal manipulationanyhow - Error handlingserde - Serializationtoml - Configuration file formatclap - Command line argument parsingThis project is licensed under the MIT License - see the LICENSE file for details.
.env file contains a valid DATABASE_URL.env file is in the correct locationpostgresql://.env fileLIMIT clauses for large result setsmatrix.enabled = falseFor issues, questions, or contributions: