docs: document SQL archive queries

This commit is contained in:
Vincent Koc 2026-05-06 01:54:34 -07:00
parent 89d35a67a4
commit 016e849e3c
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View File

@ -78,6 +78,23 @@ discrawl tui --dm
discrawl sql "select count(*) from messages;"
```
## SQL
Use `discrawl sql` for exact counts, joins, and ranking queries when normal
CLI reads are too coarse. The command is read-only by default, accepts SQL as
args or stdin, and supports `--json` for agent parsing.
Useful examples:
```bash
discrawl --json sql "select count(*) as messages from messages;"
discrawl --json sql "select coalesce(nullif(c.name, ''), m.channel_id) as channel, count(*) as messages from messages m left join channels c on c.id = m.channel_id group by m.channel_id order by messages desc limit 20;"
discrawl --json sql "select coalesce(nullif(mm.display_name, ''), nullif(mm.global_name, ''), nullif(mm.username, ''), m.author_id) as author, count(*) as messages from messages m left join members mm on mm.guild_id = m.guild_id and mm.user_id = m.author_id group by m.guild_id, m.author_id order by messages desc limit 20;"
```
Never use `--unsafe --confirm` unless the user explicitly asks for a database
mutation and the write has been reviewed.
When the installed CLI lacks a new feature, build or run from a verified
`openclaw/discrawl` checkout before concluding the feature is missing.

View File

@ -18,6 +18,8 @@
`doctor --json` control surface for launchers, automation, and CI checks.
- Refresh the repo-local `discrawl` agent skill for local Discord archive,
freshness, query, boundary, TUI, and verification workflows.
- Document `discrawl sql` read-only query examples in the repo-local agent
skill so agents can do exact archive counts and rankings safely.
### Fixes