@deaquinodev/querky 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -4
- package/dist/index.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,12 +25,19 @@ A quirky terminal SQL client with vim keybindings, schema-aware autocomplete, qu
|
|
|
25
25
|
## Requirements
|
|
26
26
|
|
|
27
27
|
- Node.js 18+
|
|
28
|
-
- pnpm
|
|
29
28
|
|
|
30
29
|
---
|
|
31
30
|
|
|
32
31
|
## Install
|
|
33
32
|
|
|
33
|
+
```bash
|
|
34
|
+
npm install -g @deaquinodev/querky
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
After that, `querky` is available globally.
|
|
38
|
+
|
|
39
|
+
### Install from source
|
|
40
|
+
|
|
34
41
|
```bash
|
|
35
42
|
git clone https://github.com/arthurdaquinosilva/querky.git
|
|
36
43
|
cd querky
|
|
@@ -39,8 +46,6 @@ pnpm build
|
|
|
39
46
|
pnpm install -g .
|
|
40
47
|
```
|
|
41
48
|
|
|
42
|
-
After that, `querky` is available globally.
|
|
43
|
-
|
|
44
49
|
---
|
|
45
50
|
|
|
46
51
|
## Connecting
|
|
@@ -116,10 +121,12 @@ Ollama is the default endpoint (`http://localhost:11434/v1`).
|
|
|
116
121
|
| `/explain-previous` | Explain the last query you ran |
|
|
117
122
|
| `/databases` | List available databases |
|
|
118
123
|
| `/tables` | List tables in the current database |
|
|
124
|
+
| `/describe <table>` | Show columns, types, and key constraints for a table |
|
|
119
125
|
| `/export csv` | Export last result to a CSV file |
|
|
120
126
|
| `/export json` | Export last result to a JSON file |
|
|
121
127
|
| `/next` | Next page of results |
|
|
122
128
|
| `/prev` | Previous page of results |
|
|
129
|
+
| `/clear` | Clear the screen and scrollback |
|
|
123
130
|
| `/toggle-vim-mode` | Toggle vim keybindings on/off |
|
|
124
131
|
| `/save <name>` | Save the last query as an alias |
|
|
125
132
|
| `/alias <name> <SQL>` | Define an alias inline |
|
|
@@ -181,6 +188,7 @@ Users coming from `psql` can use familiar meta-commands:
|
|
|
181
188
|
|---|---|
|
|
182
189
|
| `\l` | List databases |
|
|
183
190
|
| `\d` or `\dt` | List tables |
|
|
191
|
+
| `\d <table>` | Show columns for a table |
|
|
184
192
|
| `\du` | List users |
|
|
185
193
|
| `\c` | Show current database |
|
|
186
194
|
| `\c <dbname>` | Switch to a different database |
|
|
@@ -202,13 +210,28 @@ Querky starts in INSERT mode. Press `Escape` to enter NORMAL mode.
|
|
|
202
210
|
| `x` / `s` | Delete/substitute character |
|
|
203
211
|
| `D` / `C` | Delete/change to end of line |
|
|
204
212
|
| `yy` / `p` | Yank line / paste |
|
|
213
|
+
| `e` | Open current input in `$EDITOR` |
|
|
205
214
|
|
|
206
|
-
In INSERT mode, **↑↓** navigates query history.
|
|
215
|
+
In INSERT mode, **↑↓** navigates query history. **Ctrl+E** opens `$EDITOR` from INSERT mode.
|
|
207
216
|
|
|
208
217
|
Disable vim mode with `/toggle-vim-mode` or pass `--no-vim` for plain input.
|
|
209
218
|
|
|
210
219
|
---
|
|
211
220
|
|
|
221
|
+
## Shell Mode
|
|
222
|
+
|
|
223
|
+
Prefix any command with `!` to run it in your shell without leaving querky:
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
! ls -la
|
|
227
|
+
! pg_dump mydb > backup.sql
|
|
228
|
+
! cat results.csv | wc -l
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Output appears inline. ANSI colors and pipes are preserved.
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
212
235
|
## All Flags
|
|
213
236
|
|
|
214
237
|
| Flag | Default | Description |
|
package/dist/index.js
CHANGED
|
@@ -740,6 +740,7 @@ async function* streamExplain(query, baseUrl, model, apiKey) {
|
|
|
740
740
|
let res;
|
|
741
741
|
const headers = { "Content-Type": "application/json" };
|
|
742
742
|
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
743
|
+
const isDefaultOllama = baseUrl === "http://localhost:11434/v1";
|
|
743
744
|
try {
|
|
744
745
|
res = await fetch(`${baseUrl}/chat/completions`, {
|
|
745
746
|
method: "POST",
|
|
@@ -751,14 +752,20 @@ async function* streamExplain(query, baseUrl, model, apiKey) {
|
|
|
751
752
|
})
|
|
752
753
|
});
|
|
753
754
|
} catch {
|
|
754
|
-
|
|
755
|
+
if (isDefaultOllama) {
|
|
756
|
+
throw new Error(
|
|
757
|
+
"No AI model configured.\n\nOption A \u2014 run Ollama locally (free, offline):\n ollama serve\n ollama pull llama3.2\n\nOption B \u2014 use Groq (free, fast):\n querky -c <dsn> --ai-url https://api.groq.com/openai/v1 \\\n --ai-model llama-3.1-8b-instant --api-key YOUR_GROQ_KEY"
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
throw new Error(`Could not reach ${baseUrl} \u2014 check your --ai-url and connection.`);
|
|
755
761
|
}
|
|
756
762
|
if (!res.ok) {
|
|
757
763
|
const body = await res.text().catch(() => "");
|
|
758
|
-
|
|
764
|
+
const provider = isDefaultOllama ? "Ollama" : baseUrl;
|
|
765
|
+
throw new Error(`${provider} error ${res.status}: ${body || res.statusText}`);
|
|
759
766
|
}
|
|
760
767
|
const reader = res.body?.getReader();
|
|
761
|
-
if (!reader) throw new Error("No response body from
|
|
768
|
+
if (!reader) throw new Error("No response body from AI provider");
|
|
762
769
|
const decoder = new TextDecoder();
|
|
763
770
|
let buf = "";
|
|
764
771
|
while (true) {
|