microsoft / microsoft/go-sqlcmd
Feature: Native CSV output format (--csv)
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Go
- Stars
- 595
- Forks
- 91
- Avg merge
- 9h 35m
- Merged PRs (30d)
- 1
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" --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/csvpackage for proper RFC 4180 compliance
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pkg/sqlcmd/formatter.go and trace how existing output formats and the -h header option are wired into the CLI. Check the Go encoding/csv package for RFC 4180 behavior, then verify that --csv produces optional headers, quotes commas and quotes correctly, and uses UTF-8 output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100