-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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
sqlcmd -S server -Q "SELECT * FROM users" --csvExample 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/csvpackage for proper RFC 4180 compliance
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request