mssql

package
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

README


title: 'Microsoft SQL Server'

Microsoft SQL Server connector allows querying SQL Server and Azure SQL databases.

Config Schema

Field Type Required Description
type string yes constant: mssql
hosts string[] yes List of server addresses (e.g., ["localhost", "**.database.windows.net"])
user string yes Username for SQL Server Authentication
password string yes Password for SQL Server Authentication
database string yes Database name
port integer no Port number (default: 1433)
schema string no Schema name (default: "dbo")
conn_string string no Direct connection string

Config example:

type: mssql
hosts:
  - my-server.database.windows.net 
user: my_user
password: my_password
database: my_database
port: 1433
schema: dbo

Or as alternative with direct connection string:

type: mssql
conn_string: sqlserver://my_user:my_password@my-server.database.windows.net:1433?database=my_database&schema=dbo

Notes

  • The connector uses the first host in the list by default. Additional hosts can be specified for future failover implementation.
  • When using Azure SQL Database, make sure to use the full server name (*.database.windows.net).
  • The schema parameter defaults to "dbo" if not specified.
  • For named instances, include the instance name in the host: server\instance.
  • SQL Server authentication is used for connections. Windows authentication is not currently supported.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Hosts      []string `json:"hosts" yaml:"hosts"`             // List of server addresses
	User       string   `json:"user" yaml:"user"`               // Username for authentication
	Password   string   `json:"password" yaml:"password"`       // Password for authentication
	Database   string   `json:"database" yaml:"database"`       // Database name
	Port       int      `json:"port" yaml:"port"`               // Port number (default 1433)
	Schema     string   `json:"schema" yaml:"schema"`           // Schema name (default "dbo")
	ConnString string   `json:"conn_string" yaml:"conn_string"` // Direct connection string
	IsReadonly bool     `json:"is_readonly" yaml:"is_readonly"`
}

Config represents the configuration for a Microsoft SQL Server connection

func (Config) ConnectionString

func (c Config) ConnectionString() string

ConnectionString generates a connection string for Microsoft SQL Server

func (Config) Doc

func (c Config) Doc() string

Doc returns documentation about the configuration

func (Config) ExtraPrompt

func (c Config) ExtraPrompt() []string

ExtraPrompt returns additional prompt information for the configuration

func (Config) Readonly added in v0.2.1

func (c Config) Readonly() bool

func (Config) Type

func (c Config) Type() string

Type returns the type of the connector

func (*Config) UnmarshalYAML added in v0.1.0

func (c *Config) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface to allow for both direct connection string or full configuration objects in YAML

func (Config) Validate

func (c Config) Validate() error

Validate checks if the configuration is valid

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

Connector implements the connectors.Connector interface for Microsoft SQL Server

func (Connector) Config

func (c Connector) Config() connectors.Config

func (Connector) Discovery

func (c Connector) Discovery(ctx context.Context, tablesList []string) ([]model.Table, error)

func (*Connector) GuessColumnType

func (c *Connector) GuessColumnType(sqlType string) model.ColumnType

GuessColumnType implements TypeGuesser interface for MSSQL

func (*Connector) InferQuery

func (c *Connector) InferQuery(ctx context.Context, query string) ([]model.ColumnSchema, error)

InferQuery implements the Connector interface

func (Connector) LoadsColumns

func (c Connector) LoadsColumns(ctx context.Context, tableName string) ([]model.ColumnSchema, error)

func (Connector) Ping

func (c Connector) Ping(ctx context.Context) error

func (Connector) Query

func (c Connector) Query(ctx context.Context, endpoint model.Endpoint, params map[string]any) ([]map[string]any, error)

func (Connector) Sample

func (c Connector) Sample(ctx context.Context, table model.Table) ([]map[string]any, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL