## Summary Add a `--csv` flag to output query results in native CSV format. ## Use Case - Export data directly to CSV without needing to set column separator and parse manually - Integration with data analysis tools (Excel, pandas, etc.) - Scripting and automation pipelines ## Proposed Syntax ```bash sqlcmd -S server -Q "SELECT * FROM users" --csv ``` ## Example Output ``` id,name,email 1,Alice,alice@example.com 2,Bob,bob@example.com ``` ## Features - Proper handling of values containing commas (quote wrapping) - Proper handling of values containing quotes (escaping) - Optional header row (controlled by existing -h flag) - UTF-8 encoding by default ## Implementation Notes - Could leverage existing formatter infrastructure in `pkg/sqlcmd/formatter.go` - Consider using Go's standard `encoding/csv` package for proper RFC 4180 compliance
Summary
Add a
--csvflag to output query results in native CSV format.Use Case
Proposed Syntax
sqlcmd -S server -Q "SELECT * FROM users" --csvExample Output
Features
Implementation Notes
pkg/sqlcmd/formatter.goencoding/csvpackage for proper RFC 4180 compliance