db

package
v0.0.0-...-f79bcc6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MysqlDrive      = "mysql"
	PostgresDrive   = "postgres"
	ClickhouseDrive = "clickhouse"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClickHouseCfg

type ClickHouseCfg Config

type ClickhouseCtx

type ClickhouseCtx struct {
	// contains filtered or unexported fields
}

重命名的意义 在于避免使用wire自动生成代码时产生歧义

func NewClickhouseConn

func NewClickhouseConn(config *ClickHouseCfg) (*ClickhouseCtx, func(), error)

func (*ClickhouseCtx) GetConn

func (c *ClickhouseCtx) GetConn() *gorm.DB

type Config

type Config struct {
	Drive           string        `json:"drive" yaml:"drive" yml:"drive"`                   // 数据库类型
	Address         string        `json:"address" yaml:"address" yml:"address"`             // 地址
	Port            int64         `json:"port" yaml:"port" yml:"port"`                      // 端口
	User            string        `json:"user" yaml:"user" yml:"user"`                      // 用户
	Password        string        `json:"password" yaml:"password" yml:"password"`          // 密码
	DbName          string        `json:"dbName" yaml:"dbName" yml:"dbName"`                // 数据库
	Charset         string        `json:"charset" yaml:"charset" yml:"charset"`             // 字符集
	DebugModel      bool          `json:"debugModel" yaml:"debugModel" yml:"debugModel"`    // 调试模式
	MaxIdleConn     int           `json:"maxIdleConn" yaml:"maxIdleConn" yml:"maxIdleConn"` // 最大空闲链接
	MaxOpenConn     int           `json:"maxOpenConn" yaml:"maxOpenConn" yml:"maxOpenConn"` // 最大打开链接
	ParseTime       bool          `json:"parseTime" yaml:"parseTime"`
	ConnMaxLifetime time.Duration `json:"connMaxLifetime" yaml:"connMaxLifetime" yml:"connMaxLifetime"` // 链接最大复用时间
	AltHosts        []string      `json:"altHosts" yaml:"altHosts" yml:"altHosts"`                      // 从库
}

type DbCtx

type DbCtx struct {
	// contains filtered or unexported fields
}

func NewConn

func NewConn(option *Config) (dbCtx *DbCtx, clean func(), err error)

func (*DbCtx) Begin

func (c *DbCtx) Begin() *gorm.DB

func (*DbCtx) Commit

func (c *DbCtx) Commit() *gorm.DB

func (*DbCtx) GetConn

func (c *DbCtx) GetConn() *gorm.DB

func (*DbCtx) RollBack

func (c *DbCtx) RollBack() *gorm.DB

type MysqlCfg

type MysqlCfg Config

type MysqlCtx

type MysqlCtx struct {
	// contains filtered or unexported fields
}

func NewMysqlConn

func NewMysqlConn(config *MysqlCfg) (*MysqlCtx, func(), error)

func (*MysqlCtx) GetConn

func (c *MysqlCtx) GetConn() *gorm.DB

Jump to

Keyboard shortcuts

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