Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
- **In-Place Editing** - Update cells, delete rows and edit your SQL directly from the results table
- **Export your data** - Export your data as CSV, JSON, SQL, Markdown or HTML tables
- **Connection Switching** - Manage multiple databases and switch whenever you want
- **Database Exploration** - Browse schema, visualize foreign key relationships
- **Database Exploration** - Interactive schema explorer with search and foldable sections, plus foreign-key relationship trees
- **Interactive Shell** - REPL with history, multi-line, and meta-commands

See [Features](docs/features.md) for details and examples
Expand Down Expand Up @@ -293,6 +293,8 @@ See [Shell Completion](docs/completion.md)

Row limits, column widths, color schemes (`dracula`, `gruvbox`, `catppuccin-mocha`, etc.) and UI visibility options can be set through the config file at `~/.config/squix/config.yaml`.

Connections named `{service}:{env}` (e.g. `ecommerce:dev`, `ecommerce:prod`) share one saved-query library — add a query once, run it on any sibling environment. See [Shared query libraries](docs/configuration.md#shared-query-libraries).

See [Configuration](docs/configuration.md)

---
Expand Down Expand Up @@ -348,7 +350,7 @@ as part of your workflow.
- [x] Move saved configs from top level yaml file to per-connection sql files
- [x] Display counters for selected lines and search results
- [x] Allow different connections to share query collection (eg. dev, stg, prod)
- [ ] Rework database exploration commands
- [x] Rework database exploration commands
- [ ] Option to encrypt sensitive data in the config file

---
Expand Down
17 changes: 13 additions & 4 deletions SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ description: Run SQL queries across databases (Postgres, MySQL, SQLite, etc.) vi

Squix is a CLI tool for managing and executing SQL queries across multiple
databases (PostgreSQL, MySQL, SQLite, Oracle, SQL Server, ClickHouse, Firebird).
It stores named queries in `~/.config/squix/config.yaml`.
It stores named queries as `.sql` files in `~/.config/squix/queries/`.

**Shared query libraries:** Connections named `{service}:{env}` (e.g. `ecommerce:dev`, `ecommerce:prod`) share one query library keyed by service — a query added on one is visible on siblings. `conn_string` stays per-connection. See [docs/configuration.md](docs/configuration.md#shared-query-libraries).

## Critical Rules

Expand Down Expand Up @@ -47,10 +49,17 @@ squix run list_users -f json # always use -f
## Explore Schema

```bash
squix explore # List all tables (non-interactive, prints to stdout)
squix explain orders -d 2 # Show FK relationships as ASCII tree
squix explore # Interactive schema explorer TUI (tables + views)
squix explore --oneline # Non-interactive: print table/view names one per line
squix explore --oneline --tables # tables only (--views for views only)
squix explain orders -d 2 # Show FK relationships as ASCII tree
```

Explorer TUI keys: `enter`=SELECT *, `c`=columns, `r`=relationships,
`Tab`=fold section, `/`=search. Defaults can be overridden by adding
`explorer_*` entries under `keybindings:` in config.yaml — see
docs/keybindings.md.

## List Queries

```bash
Expand Down Expand Up @@ -82,7 +91,7 @@ echo y | squix remove -c mydb # Delete connection (needs confirmation)
- `squix run <query>` without `-f` on a SELECT — opens TUI
- `squix shell` — interactive REPL
- `squix edit` — opens `$EDITOR`
- `squix explore` — interactive schema explorer TUI (use `--oneline`)
- `squix explore <table>` — opens TUI
- `squix info` — opens TUI
- `squix add <name>` without SQL — opens `$EDITOR`
- `squix run` with no args — opens `$EDITOR`
14 changes: 2 additions & 12 deletions cmd/squix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"strings"

"github.com/eduardofuncao/squix/internal/config"
"github.com/eduardofuncao/squix/internal/db"
"github.com/eduardofuncao/squix/internal/editor"
"github.com/eduardofuncao/squix/internal/styles"
Expand All @@ -20,15 +19,7 @@ func (a *App) handleAdd() {
printError("No active connection. Use 'squix switch <connection>' or 'squix init' first")
}

_, ok := a.config.Connections[a.config.CurrentConnection]
if !ok {
a.config.Connections[a.config.CurrentConnection] = &config.ConnectionYAML{}
}
conn := a.config.Connections[a.config.CurrentConnection]
if conn.Queries == nil {
conn.Queries = make(map[string]db.Query)
}
queries := conn.Queries
queries := a.config.QueriesFor(a.config.CurrentConnection)

Comment on lines 19 to 23
queryName := os.Args[2]
var querySQL string
Expand Down Expand Up @@ -68,6 +59,5 @@ func (a *App) handleAdd() {
printError("Could not save configuration file: %v", err)
}

fmt.Println(styles.Success.Render(fmt.Sprintf("✓ Added query '%s' with ID %d", queryName, queries[queryName].Id)))
fmt.Println(styles.Success.Render(fmt.Sprintf("✓ Added query '%s'", queryName)))
}

10 changes: 4 additions & 6 deletions cmd/squix/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,12 @@ func (a *App) Run() {
a.handleListConnections()
case "edit":
a.handleEdit()
case "info":
a.handleInfo()
case "explore":
a.handleExplore()
case "status", "st", "test":
a.handleStatus()
case "history":
a.handleHistory()
case "tables", "t":
a.handleTables()
case "disconnect", "clear", "unset":
a.handleDisconnect()
case "config":
Expand Down Expand Up @@ -107,10 +103,12 @@ func (a *App) printUsage() {
),
)
fmt.Println(
" squix tables " + styles.Faint.Render("List database tables"),
" squix explore " + styles.Faint.Render(
"Explore database schema",
),
)
fmt.Println(
" squix tables <table> " + styles.Faint.Render(
" squix explore <table> " + styles.Faint.Render(
"Query a table directly",
),
)
Expand Down
15 changes: 4 additions & 11 deletions cmd/squix/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ func getCompletions(args []string, cfg *config.Config) []string {
result := []string{"queries", "connections"}
result = append(result, getCurrentConnectionQueries(cfg)...)
return result
case "info":
if len(args) >= 2 {
return []string{"table", "view"}
}
return []string{"table", "view"}
case "explore":
return []string{"--oneline", "--tables", "--views"}
case "edit", "delete", "rm", "remove":
return getCurrentConnectionQueries(cfg)
case "--connection", "-c":
Expand All @@ -123,13 +120,10 @@ func getSubcommands() []string {
"list",
"ls",
"edit",
"info",
"explore",
"status",
"test",
"history",
"tables",
"t",
"disconnect",
"clear",
"unset",
Expand All @@ -154,13 +148,12 @@ func getCurrentConnectionQueries(cfg *config.Config) []string {
return []string{}
}

conn, exists := cfg.Connections[cfg.CurrentConnection]
if !exists {
if _, exists := cfg.Connections[cfg.CurrentConnection]; !exists {
return []string{}
}

var names []string
for name := range conn.Queries {
for name := range cfg.QueriesFor(cfg.CurrentConnection) {
names = append(names, name)
}
sort.Strings(names)
Expand Down
Loading
Loading