Skip to content

Implement -D flag for ODBC DSN (Data Source Name) support #629

@dlevy-msft-sql

Description

@dlevy-msft-sql

Summary

The ODBC sqlcmd supports a -D flag that allows connecting using an ODBC Data Source Name (DSN) instead of specifying connection parameters directly.

Current State

  • The -D flag is not implemented in go-sqlcmd
  • Linux ODBC sqlcmd supports this for using pre-configured DSNs

Requested Behavior

When -D is specified, the -S parameter should be interpreted as a DSN name rather than a server name. The DSN would be looked up from the system's ODBC configuration (e.g., /etc/odbc.ini\ on Linux or ODBC Data Source Administrator on Windows).

Considerations

  • go-sqlcmd uses go-mssqldb directly, not ODBC, so implementing DSN support would require:
    • Parsing ODBC ini files to extract connection parameters
    • Or, using CGO to call ODBC APIs (which would add complexity)
  • This may require a design discussion to determine the best approach

References

  • ODBC sqlcmd usage: -S <DSN_name> -D\ indicates that -S\ refers to a DSN

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions