Skip to content

feat: export query results to CSV, JSON, SQL INSERT, and TSV#23

Merged
muk2 merged 2 commits intomainfrom
feature/issue-13-export-results
Feb 19, 2026
Merged

feat: export query results to CSV, JSON, SQL INSERT, and TSV#23
muk2 merged 2 commits intomainfrom
feature/issue-13-export-results

Conversation

@muk2
Copy link
Owner

@muk2 muk2 commented Feb 18, 2026

Summary

Adds multi-format export for query results, addressing #13.

  • Ctrl+S in results view opens export format picker
  • 5 export formats: CSV, JSON, SQL INSERT, TSV, clipboard copy
  • Format picker dialog — navigate with arrow keys, quick-select with 1-5, or press Enter
  • Timestamped filenamespgrsql_export_YYYYMMDD_HHMMSS.{ext}
  • Proper escaping — CSV quoting, SQL single-quote escaping, JSON type mapping
  • NULL handling — empty in CSV, null in JSON, NULL in SQL

Export Formats

Format Behavior
CSV RFC 4180 compliant with proper quoting
JSON Pretty-printed array of objects with correct types
SQL INSERT Individual INSERT statements with proper escaping
TSV Tab-separated with tab chars replaced in values
Clipboard CSV format copied to system clipboard

Changes

File Change
src/export.rs New module: to_csv(), to_json(), to_sql_insert(), to_tsv() with helpers
src/main.rs Added mod export
src/ui/app.rs Added ExportFormat enum, Focus::ExportPicker, handle_export_input(), perform_export()
src/ui/components.rs Added draw_export_picker() dialog, updated help overlay

Test plan

  • All 133 tests pass (9 new export tests)
  • Clippy clean
  • cargo fmt clean
  • Verify Ctrl+S opens format picker from results
  • Verify 1-5 quick-select exports in correct format
  • Verify CSV output has proper quoting/escaping
  • Verify JSON output has correct types (numbers, booleans, nulls)
  • Verify SQL INSERT output has proper single-quote escaping
  • Verify clipboard copy works
  • Verify file is saved with correct extension

Closes #13

🤖 Generated with Claude Code

muk2 and others added 2 commits February 18, 2026 19:27
Add Ctrl+S in results view to open an export format picker dialog.
Supports exporting to CSV, JSON, SQL INSERT statements, TSV, or
copying to clipboard. Files are saved with timestamped filenames
(pgrsql_export_YYYYMMDD_HHMMSS.ext). Proper handling of NULL values,
special characters, and SQL escaping across all formats.

- New src/export.rs module with format-specific serializers
- Export format picker dialog with keyboard navigation (1-5 quick select)
- 9 unit tests for export formatting and edge cases
- Help overlay updated with Ctrl+S keybinding

Closes #13

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Combine imports from both branches: EXPORT_FORMATS from the export
feature and is_sql_function from the advanced SQL highlighting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@muk2 muk2 merged commit 202f34a into main Feb 19, 2026
8 of 9 checks passed
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.

Feature: Export query results to CSV, JSON, and INSERT statements

1 participant