db

package
v1.2.9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Mysql     = "mysql"
	Postgres  = "postgres"
	Sqlite    = "sqlite3"
	Sqlserver = "sqlserver"
)

Variables

This section is empty.

Functions

func MysqlDsn

func MysqlDsn(opt Option) string

func Open

func Open(option Option) (*sql.DB, error)

Open returns a *sql.DB with the give Option

func PostgresDsn

func PostgresDsn(opt Option) string

func SQLServerDsn

func SQLServerDsn(opt Option) string

func SQLiteDsn

func SQLiteDsn(opt Option) string

Types

type Option

type Option struct {
	Driver             string        `mapstructure:"driver"`
	Address            string        `mapstructure:"address"`
	User               string        `mapstructure:"user"`
	Password           string        `mapstructure:"password"`
	Database           string        `mapstructure:"database"`
	Params             string        `mapstructure:"param"`
	MaxIdleConnections int           `mapstructure:"maxIdleConnections"`
	MaxOpenConnections int           `mapstructure:"maxOpenConnections"`
	MaxLifeTime        time.Duration `mapstructure:"maxLifeTime"`
	MaxIdleTime        time.Duration `mapstructure:"maxIdleTime"`
}

Option is database connection option

Jump to

Keyboard shortcuts

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