|
| 1 | +--- |
| 2 | +title: "Configuration" |
| 3 | +description: "Global CLI options, environment variables, and deployment configuration." |
| 4 | +icon: "settings" |
| 5 | +--- |
| 6 | + |
| 7 | +# Configuration |
| 8 | + |
| 9 | +## Global CLI Options |
| 10 | + |
| 11 | +These options apply to all database subcommands and must be placed **before** the subcommand. |
| 12 | + |
| 13 | +```bash |
| 14 | +sql-studio [OPTIONS] <SUBCOMMAND> [ARGS...] |
| 15 | +``` |
| 16 | + |
| 17 | +| Option | Short | Description | Default | Env Var | |
| 18 | +|--------|-------|-------------|---------|---------| |
| 19 | +| `--address` | `-a` | Address and port to bind to | `127.0.0.1:3030` | `ADDRESS` | |
| 20 | +| `--timeout` | `-t` | Timeout for queries from the query page | `5secs` | `TIMEOUT` | |
| 21 | +| `--base-path` | `-b` | Base URL path for the UI (e.g. `/sql-studio`) | _(none)_ | `BASE_PATH` | |
| 22 | +| `--no-browser` | | Don't open the URL in the system browser | `false` | `NO_BROWSER` | |
| 23 | +| `--no-shutdown` | | Don't show the shutdown button in the UI | `false` | `NO_SHUTDOWN` | |
| 24 | + |
| 25 | +### Timeout Format |
| 26 | + |
| 27 | +The `--timeout` option accepts human-readable durations: `5secs`, `30secs`, `1min`, `2min 30secs`, etc. |
| 28 | + |
| 29 | +### Examples |
| 30 | + |
| 31 | +```bash |
| 32 | +# Custom address and longer timeout |
| 33 | +sql-studio --address 0.0.0.0:8080 --timeout 30secs sqlite ./my.db |
| 34 | + |
| 35 | +# Serve under a base path |
| 36 | +sql-studio --base-path /sql-studio sqlite ./my.db |
| 37 | +``` |
| 38 | + |
| 39 | +## Environment Variables |
| 40 | + |
| 41 | +Every CLI option can be set via an environment variable. This is particularly useful for Docker deployments or CI environments. |
| 42 | + |
| 43 | +```bash |
| 44 | +export ADDRESS="0.0.0.0:3030" |
| 45 | +export TIMEOUT="30secs" |
| 46 | +export BASE_PATH="/sql-studio" |
| 47 | +export NO_BROWSER="true" |
| 48 | +export NO_SHUTDOWN="true" |
| 49 | + |
| 50 | +sql-studio sqlite ./my.db |
| 51 | +``` |
| 52 | + |
| 53 | +## Logging |
| 54 | + |
| 55 | +SQL Studio uses the `tracing` crate with `env-filter` support. Control log verbosity with the `RUST_LOG` environment variable: |
| 56 | + |
| 57 | +```bash |
| 58 | +# Show info-level logs |
| 59 | +RUST_LOG=info sql-studio sqlite ./my.db |
| 60 | + |
| 61 | +# Show debug-level logs |
| 62 | +RUST_LOG=debug sql-studio sqlite ./my.db |
| 63 | + |
| 64 | +# Show only SQL Studio logs |
| 65 | +RUST_LOG=sql_studio=debug sql-studio sqlite ./my.db |
| 66 | +``` |
| 67 | + |
| 68 | +## Deployment |
| 69 | + |
| 70 | +### Reverse Proxy |
| 71 | + |
| 72 | +When deploying behind a reverse proxy (e.g. Nginx, Caddy, Traefik), use the `--base-path` option so all UI routes are served under a prefix: |
| 73 | + |
| 74 | +```bash |
| 75 | +sql-studio --base-path /sql-studio --no-browser --no-shutdown sqlite ./my.db |
| 76 | +``` |
| 77 | + |
| 78 | +Then configure your reverse proxy to forward `/sql-studio/*` to `http://127.0.0.1:3030/sql-studio/`. |
| 79 | + |
| 80 | +### Docker |
| 81 | + |
| 82 | +```bash |
| 83 | +docker run -p 3030:3030 frectonz/sql-studio /bin/sql-studio \ |
| 84 | + --no-browser \ |
| 85 | + --no-shutdown \ |
| 86 | + --address=0.0.0.0:3030 \ |
| 87 | + postgres \ |
| 88 | + postgresql://user:pass@host/mydb |
| 89 | +``` |
| 90 | + |
| 91 | +For file-based databases (SQLite, DuckDB, Parquet, CSV), mount a volume: |
| 92 | + |
| 93 | +```bash |
| 94 | +docker run -p 3030:3030 \ |
| 95 | + -v /path/to/data:/data \ |
| 96 | + frectonz/sql-studio /bin/sql-studio \ |
| 97 | + --no-browser \ |
| 98 | + --no-shutdown \ |
| 99 | + --address=0.0.0.0:3030 \ |
| 100 | + sqlite /data/my-database.db |
| 101 | +``` |
0 commit comments