database

package
v0.5.10 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DSNREnvRegex = regexp.MustCompile(`\$\{([A-Za-z0-9_]+)\}`)

Functions

func ResolveDatabaseName added in v0.5.5

func ResolveDatabaseName(opts ConnectOptions) string

ResolveDatabaseName returns the database opts would connect to, merging the DSN path with the structured field. Empty when neither supplies one.

Types

type ConnectOptions added in v0.4.0

type ConnectOptions struct {
	DSN string

	Scheme   string
	Host     string
	Port     string
	Database string

	User     string
	Password string

	Params map[string]string
}

ConnectOptions represents the structured configuration used to build a DSN. Any field may include ${ENV_VAR} placeholders that will be expanded before use.

type DbEngine

type DbEngine uint8
const (
	Unknown DbEngine = iota
	MySQL
	PostgreSQL
	SQLite
	MSSQL
	Oracle
	HDB
	Vertica
)

func Connect

func Connect(ctx context.Context, opts ConnectOptions) (*sql.DB, DbEngine, error)

func ConnectMany added in v0.5.5

func ConnectMany(ctx context.Context, opts ConnectOptions, dbNames []string) (map[string]*sql.DB, DbEngine, error)

ConnectMany opens one *sql.DB per name in dbNames. On any per-database failure, every handle opened so far is closed before returning the error.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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