datasource

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DriverBigQuery             = "bigquery"
	DriverMySQL                = "mysql"
	DriverPostgres             = "postgres"
	DriverSQLite3              = "sqlite3"
	SchemePostgres             = "postgres"
	DefaultPortMySQL    uint16 = 3306
	DefaultPortPostgres uint16 = 5432
)
View Source
const (
	SSLModeAllow      = "allow"
	SSLModeDisable    = "disable"
	SSLModePrefer     = "prefer"
	SSLModeRequire    = "require"
	SSLModeVerifyCA   = "verify-ca"
	SSLModeVerifyFull = "verify-full"
	SSLModeDefault    = SSLModeDisable
)

Variables

View Source
var ErrSSLModeNotSUpported = errors.New("sslmode not supported")

Functions

func SSLModeParse

func SSLModeParse(s string) (string, error)

func SSLModeParseOrDefault

func SSLModeParseOrDefault(s, d string) string

Types

type DataSource

type DataSource struct {
	Driver   string `json:"driver"`
	DSN      string `json:"dsn"`
	Hostname string `json:"hostname"` // does not include port
	Port     uint16 `json:"port"`     // 0-65535
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
	Database string `json:"database,omitempty"`
	SSLMode  string `json:"sslmode,omitempty"`
}

func (DataSource) Host

func (ds DataSource) Host() string

func (DataSource) HostnameOrDefault added in v0.46.0

func (ds DataSource) HostnameOrDefault() string

func (DataSource) Name added in v0.46.0

func (ds DataSource) Name() (string, error)

Name produces a URI DSN connection string

func (DataSource) Open added in v0.46.0

func (ds DataSource) Open() (*sql.DB, error)

func (DataSource) PortOrDefault

func (ds DataSource) PortOrDefault() uint16

func (DataSource) UserPassword

func (ds DataSource) UserPassword() string

Jump to

Keyboard shortcuts

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