db

package
v0.2.37 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_DSN                 = "datasource.dsn"
	DB_URL_KEY             = "datasource.url"
	DB_USERNAME_KEY        = "datasource.username"
	DB_PWD_KEY             = "datasource.password"
	DB_CONN_MAX_LIFE_TIME  = "datasource.connMaxLifetime"
	DB_MAX_IDLE_CONNS      = "datasource.maxIdleConns"
	DB_MAX_OPEN_CONNS      = "datasource.maxOpenConns"
	DefaultConnMaxLifetime = 30 * time.Minute
	DefaultMaxIdleConns    = 10
	DefaultMaxOpenConns    = 50
)

Variables

This section is empty.

Functions

func CreateInsertSql

func CreateInsertSql(tableName string, kv map[string]interface{}) (sql string, values []interface{})

func Expr added in v0.1.9

func Expr(expr string, args ...interface{}) clause.Expr

func Get

func Get() *dataSource

func InitDataSource

func InitDataSource(option Option)

Types

type Option

type Option struct {
	DSN string
	//打开数据库连接的最大数量,默认DefaultMaxOpenConns
	MaxOpenConns int
	//空闲连接池中连接的最大数量,默认DefaultMaxIdleConns
	MaxIdleConns int
	//连接可复用的最大时间。单位分钟,默认DefaultConnMaxLifetime
	ConnMaxLifetime int
}

Jump to

Keyboard shortcuts

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