microsoft / microsoft/go-sqlcmd

Feature: Native CSV output format (--csv)

Open
#620 0 comments 4 reactions 0 assignees View on GitHub

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/csv package for proper RFC 4180 compliance

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.