datasource

package
v0.61.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DriverBigQuery             = "bigquery"
	DriverGodror               = "godror"
	DriverMySQL                = "mysql"
	DriverOracle               = "oracle"
	DriverPostgres             = "postgres"
	DriverSQLite3              = "sqlite3"
	SchemePostgres             = "postgres"
	DefaultPortMySQL    uint16 = 3306
	DefaultPortPostgres uint16 = 5432
)
View Source
const (
	OracleParamConnectTimeout = "connect_timeout"

	PgSSLModeParam    = "sslmode"
	SSLModeAllow      = "allow"
	SSLModeDisable    = "disable"
	SSLModePrefer     = "prefer"
	SSLModeRequire    = "require"
	SSLModeVerifyCA   = "verify-ca"
	SSLModeVerifyFull = "verify-full"
	SSLModeDefault    = SSLModeDisable
)

Variables

View Source
var (
	ErrDriverNameEmpty    = errors.New("driver name cannot be empty")
	ErrDriverNotSupported = errors.New("driver not supported")
)
View Source
var ErrSSLModeNotSUpported = errors.New("sslmode not supported")

Functions

func ExampleGodrorQueryParams added in v0.47.0

func ExampleGodrorQueryParams() map[string][]string

func ExampleOracleQueryParams added in v0.47.0

func ExampleOracleQueryParams() map[string][]string

func SSLModeParse

func SSLModeParse(s string) (string, error)

SSLModeParse parses Postgres sslmode query param

func SSLModeParseOrDefault

func SSLModeParseOrDefault(s, d string) string

SSLModeParseOrDefault manages Postgres sslmode query param

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"`
	Query    map[string][]string `json:"query,omitempty"`
}

func (DataSource) Host

func (ds DataSource) Host() string

func (DataSource) HostDatabase added in v0.47.0

func (ds DataSource) HostDatabase(sep string) string

func (DataSource) HostDatabaseQuery added in v0.47.0

func (ds DataSource) HostDatabaseQuery(sep string) string

HostDatabaseQuery can be used when there's no need to validate query params

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) UserPassHostDatabase added in v0.47.0

func (ds DataSource) UserPassHostDatabase() string

func (DataSource) UserPassHostDatabaseQuery added in v0.47.0

func (ds DataSource) UserPassHostDatabaseQuery() string

UserPassHostDatabaseQuery can be used when there's no need to validate query params

func (DataSource) UserPassword

func (ds DataSource) UserPassword() string

type DataSourceSet added in v0.58.0

type DataSourceSet struct {
	Data map[string]DataSource
}

func (DataSourceSet) GetDataSource added in v0.58.0

func (dss DataSourceSet) GetDataSource(key string) (DataSource, error)

func (DataSourceSet) Keys added in v0.58.0

func (dss DataSourceSet) Keys() []string

Jump to

Keyboard shortcuts

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