Skip to content

CLI

Query history

dbcode history prints the queries in your query history, the same rows the History view shows when you open it as a table. It reads the history from your editor profile, so the editor does not need to be running.

Terminal window
dbcode history --since 2026-11-03
dbcode history -c prod --since 2026-11-03 --until 2026-11-10 --format csv
  • --since keeps queries run on or after a date or time; --until keeps queries run before one. A plain date such as 2026-11-03 means midnight at the start of that day in your time zone. A date and time such as 2026-11-03T09:00 works too.
  • -c keeps queries run on one connection, by name or id.
  • --format works as for dbcode query: a table on a terminal, JSON when piped, or csv, tsv, jsonl and markdown.
  • --app and --profile pick the editor and profile whose history to read.

Rows are newest first. Each has date, sql, connection, driver, actor (User or AI), client, surface, database, schema, duration (milliseconds), rows, affected, error, id, device id and session id. date is in UTC, in ISO 8601 format, so any language can parse it.

With history sync turned on, the output includes the queries synced from your other devices.

This saves yesterday’s queries to a file named after the day (on Linux, use date -d yesterday +%F for the first line):

Terminal window
day=$(date -v-1d +%F)
dbcode history --since "$day" --until "$(date +%F)" > "history-$day.json"

Run it each day with cron, or with Task Scheduler on Windows.

In a VS Code window connected to a Dev Container, an SSH host or WSL, dbcode history prints the history of that window’s DBCode.