Skip to content

Add export CLI command for CSV/JSON data export#27

Open
nandanadileep wants to merge 1 commit into
roeimichael:mainfrom
nandanadileep:feat/issue-13-export
Open

Add export CLI command for CSV/JSON data export#27
nandanadileep wants to merge 1 commit into
roeimichael:mainfrom
nandanadileep:feat/issue-13-export

Conversation

@nandanadileep

Copy link
Copy Markdown

Summary

Fixes #13 by adding a direct database export path for users who want to analyze trends externally, share cost data, or back up before clear.

  • context-analyzer-tool export with --format csv|json, required --table, optional --output, and optional --days
  • Supports events, tasks, snapshots (maps to token_snapshots), and anomalies
  • Opens the local SQLite DB directly (same pattern as prune)
  • New db/export.py module for row fetching and serialization
  • Tests cover day filtering, table aliases, CSV/JSON formatting, and CLI file/stdout output

Usage

context-analyzer-tool export --format csv --table tasks --output tasks.csv
context-analyzer-tool export --format json --table anomalies
context-analyzer-tool export --format csv --table snapshots --days 7

Test plan

  • uv run pytest tests/test_export.py -q (7 passed)
  • uv run ruff check on changed files
  • Export each table to CSV and open in a spreadsheet
  • Verify --days 7 only includes recent rows

Made with Cursor

Let users extract events, tasks, snapshots, and anomalies from the
local SQLite database for backup, sharing, or spreadsheet analysis.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add export CLI command for CSV/JSON data export

1 participant