

A hybrid CLI & Web tool to run SQL queries on CSV, XLSX, and JSON files, written in Go.
A hybrid CLI & Web tool to run SQL queries on CSV, XLSX, and JSON files, written in Go.
go-sqlite3)# Clone or download the repository
git clone https://github.com/zulfikawr/runsql
cd runsql
# Install dependencies
go mod download
# Build the executable
go build -o runsql ./cmd/runsql
# or
go build -o runsql.exe ./cmd/runsql # for Windows
Download the compiled executable from the Releases page.
Execute SQL queries directly from the terminal.
./runsql -f <file> -q <query> -o <format>
| Flag | Description | Default | Example |
|---|---|---|---|
-f | File path (CSV, XLSX, or JSON) | Required | -f data/sales.csv |
-q | SQL query | Required | -q "SELECT * FROM sales LIMIT 10" |
-o | Output format: table, json, csv | table | -o json |
Example 1: Query CSV with table output
./runsql -f sample/sample.csv -q "SELECT industry, COUNT(*) as count FROM sample WHERE level = 0 GROUP BY industry" -o table
Output:
| industry | count |
+----------+-------+
| total | 705 |Example 2: Query JSON with JSON output
./runsql -f sample/sample.json -q "SELECT language, COUNT(*) as users FROM sample GROUP BY language ORDER BY users DESC" -o json
Output:
[
{
"language": "Sindhi",
"users": 1000
}
]
Example 3: Query with CSV output
./runsql -f data.csv -q "SELECT name, email FROM data WHERE age > 30" -o csv
Output:
name,email
John Doe,[email protected]
Jane Smith,[email protected]
Example 4: JOIN Query (Multi-File)
./runsql -f users.csv,orders.json -q "SELECT users.name, orders.item FROM users JOIN orders ON users.id = orders.user_id"
Launch an interactive web interface for querying files.
./runsql -web -addr ":8080"
| Flag | Description | Default |
|---|---|---|
-web | Enable web mode | false (CLI mode) |
-addr | Server address (host:port) | :8080 |
./runsql -web -addr ":3000"
Then open your browser to http://localhost:3000 and:
runsql/
โโโ cmd/
โ โโโ runsql/ # Entry point
โ โโโ main.go # CLI/Web mode dispatcher
โโโ internal/
โ โโโ adapter/ # Interface adapters (Ports & Adapters pattern)
โ โ โโโ cli/ # CLI-specific logic
โ โ โ โโโ cli.go
โ โ โโโ web/ # HTTP handlers & server
โ โ โโโ web.go
โ โโโ core/ # Business logic (The Brain)
โ โ โโโ domain.go # Struct definitions
โ โ โโโ engine.go # SQLite lifecycle & query execution
โ โ โโโ engine_test.go # Unit tests
โ โ โโโ infer.go # Type inference logic
โ โโโ parsers/ # File readers (Ports)
โ โ โโโ parser.go # Interface definition
โ โ โโโ csv.go # CSV parser
โ โ โโโ json.go # JSON parser
โ โ โโโ xlsx.go # Excel parser
โ โ โโโ parsers_test.go # Unit tests
โ โโโ ui/ # UI logic
โ โโโ colors.go # Colors definition
โโโ web/ # Static frontend assets
โ โโโ index.html # Web UI
โ โโโ script.js # JavaScript
โ โโโ style.css # Styling
โโโ go.mod # Go module definition
โโโ go.sum # Go module lock file
โโโ LICENSE # MIT License
โโโ .gitignore # Git ignore rules
โโโ README.md # This fileRunSQL follows the Hexagonal Architecture (Ports & Adapters) pattern:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Interfaces โ
โ (CLI Adapter) โ (Web Adapter) โ
โโโโโโโ