dirsql 0.3.120 → 0.3.122
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.
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Query files without a config
|
|
2
|
+
|
|
3
|
+
You have a directory and a question about the files in it. You want an answer
|
|
4
|
+
now — not a `.dirsql.toml`, not a schema, not a setup step. Point `dirsql` at
|
|
5
|
+
the directory and write a path where a table name goes.
|
|
6
|
+
|
|
7
|
+
## 1. Run a query against the directory
|
|
8
|
+
|
|
9
|
+
No config, no install ceremony — `uvx` (or `npx`) fetches and runs `dirsql`,
|
|
10
|
+
rooted at the directory you run it from:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
uvx dirsql query "SELECT basename, size FROM './' ORDER BY size DESC LIMIT 5"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
[
|
|
18
|
+
{"basename":"video.mp4","size":84213770},
|
|
19
|
+
{"basename":"archive.zip","size":9123400},
|
|
20
|
+
{"basename":"notes.md","size":40213},
|
|
21
|
+
{"basename":"todo.md","size":1200},
|
|
22
|
+
{"basename":"README.md","size":840}
|
|
23
|
+
]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`'./'` stands in for a table you never declared. `dirsql` scans the directory
|
|
27
|
+
live and hands SQLite one row per file — this is a
|
|
28
|
+
[path-table](../reference/path-tables.md). Because there is no `-c`, there are
|
|
29
|
+
**no named tables** at all; the path *is* the query
|
|
30
|
+
([configless mode](../reference/cli.md#configless-mode)).
|
|
31
|
+
|
|
32
|
+
## 2. Ask about content, not just names
|
|
33
|
+
|
|
34
|
+
Every file exposes the seven [stat columns](../reference/columns.md) (`path`,
|
|
35
|
+
`basename`, `dir`, `ext`, `size`, `mtime`, `ctime`) plus a hidden `content`
|
|
36
|
+
column. `content` is read only when you name it, so filtering on it is cheap
|
|
37
|
+
until you actually ask:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uvx dirsql query "SELECT path FROM './docs/**/*.md' WHERE content LIKE '%deprecated%'"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The `./` prefix is required. A bare glob is rejected with a hint rather than
|
|
44
|
+
silently guessed:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
uvx dirsql query "SELECT * FROM '**/*.md'"
|
|
48
|
+
-- no such table: **/*.md; did you mean './**/*.md'?
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 3. Graduate to a named table when it pays off
|
|
52
|
+
|
|
53
|
+
A path-table re-scans the filesystem on every query — perfect for a one-off
|
|
54
|
+
question over a few hundred files, wasteful for a large tree you query
|
|
55
|
+
repeatedly. When that day comes, [declare a table](./define-tables.md): it is
|
|
56
|
+
indexed once, kept fresh by the watcher, and can persist across restarts. The
|
|
57
|
+
zero-config query is the floor; a named table is the escalation path — nothing
|
|
58
|
+
you write here has to be thrown away to get there.
|
|
59
|
+
|
|
60
|
+
## Notes
|
|
61
|
+
|
|
62
|
+
- The same query works from the SDK: construct `DirSQL` with neither a
|
|
63
|
+
`config` nor `tables` and call `query("SELECT * FROM './'")`
|
|
64
|
+
([SDK reference](../reference/sdk.md)).
|
|
65
|
+
- Paths outside the root resolve too — `'/var/log/*.log'`, `'../notes'`,
|
|
66
|
+
`'~/notes/*.md'` — reporting absolute paths
|
|
67
|
+
([path-tables reference](../reference/path-tables.md#paths-outside-the-index-root)).
|
|
68
|
+
- `node_modules/` and `.git/` are skipped by default so a bare `'./'` does not
|
|
69
|
+
drown in machinery ([skip rules](../reference/path-tables.md#skip-rules)).
|
|
@@ -120,10 +120,26 @@ A path-table is scanned when the statement runs, so it always reflects the
|
|
|
120
120
|
filesystem as it is *now* — unlike declared tables, which are indexed on build
|
|
121
121
|
and updated by the watcher. A file created a moment ago shows up immediately.
|
|
122
122
|
|
|
123
|
+
The scan is live all the way down to `content`: a file's body is read when the
|
|
124
|
+
query names the `content` column, not when the row is discovered. A file
|
|
125
|
+
deleted *after* the scan finds it but *before* its `content` is read yields
|
|
126
|
+
`NULL` content — the same NULL an unreadable or non-UTF-8 file gives — rather
|
|
127
|
+
than failing the query. This is an accepted consequence of reading live, not a
|
|
128
|
+
bug to design around.
|
|
129
|
+
|
|
123
130
|
Path-tables are per-connection and are never written to a persistent cache, so
|
|
124
131
|
they cannot leak into `sqlite_master` or survive a restart. The reserved
|
|
125
132
|
top-level `.dirsql/` directory is excluded from the scan, as everywhere else.
|
|
126
133
|
|
|
134
|
+
### When to promote to a declared table
|
|
135
|
+
|
|
136
|
+
Every query re-scans the filesystem: a path-table has no index, no watcher, and
|
|
137
|
+
no persistent cache. That is the right trade for a hundreds-of-files, run-it-once
|
|
138
|
+
question. When the same tree is queried repeatedly, or is large, declare a
|
|
139
|
+
[table](/reference/config) for it instead — a declared table is indexed on
|
|
140
|
+
build, kept fresh by the watcher, and (with `--persist`) survives restarts, so
|
|
141
|
+
its rows are read from SQLite rather than re-walked each time.
|
|
142
|
+
|
|
127
143
|
## Skip rules
|
|
128
144
|
|
|
129
145
|
A path-table scan applies the same [`ignore`](/reference/config) patterns your
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dirsql",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.122",
|
|
4
4
|
"description": "Ephemeral SQL index over a local directory",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/thekevinscott/dirsql",
|
|
@@ -212,15 +212,15 @@
|
|
|
212
212
|
]
|
|
213
213
|
},
|
|
214
214
|
"optionalDependencies": {
|
|
215
|
-
"@dirsql/lib-linux-x64-gnu": "0.3.
|
|
216
|
-
"@dirsql/lib-linux-arm64-gnu": "0.3.
|
|
217
|
-
"@dirsql/lib-darwin-x64": "0.3.
|
|
218
|
-
"@dirsql/lib-darwin-arm64": "0.3.
|
|
219
|
-
"@dirsql/lib-win32-x64-msvc": "0.3.
|
|
220
|
-
"@dirsql/cli-linux-x64-gnu": "0.3.
|
|
221
|
-
"@dirsql/cli-linux-arm64-gnu": "0.3.
|
|
222
|
-
"@dirsql/cli-darwin-x64": "0.3.
|
|
223
|
-
"@dirsql/cli-darwin-arm64": "0.3.
|
|
224
|
-
"@dirsql/cli-win32-x64-msvc": "0.3.
|
|
215
|
+
"@dirsql/lib-linux-x64-gnu": "0.3.122",
|
|
216
|
+
"@dirsql/lib-linux-arm64-gnu": "0.3.122",
|
|
217
|
+
"@dirsql/lib-darwin-x64": "0.3.122",
|
|
218
|
+
"@dirsql/lib-darwin-arm64": "0.3.122",
|
|
219
|
+
"@dirsql/lib-win32-x64-msvc": "0.3.122",
|
|
220
|
+
"@dirsql/cli-linux-x64-gnu": "0.3.122",
|
|
221
|
+
"@dirsql/cli-linux-arm64-gnu": "0.3.122",
|
|
222
|
+
"@dirsql/cli-darwin-x64": "0.3.122",
|
|
223
|
+
"@dirsql/cli-darwin-arm64": "0.3.122",
|
|
224
|
+
"@dirsql/cli-win32-x64-msvc": "0.3.122"
|
|
225
225
|
}
|
|
226
226
|
}
|