dbutil

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(option *Option) (*gorm.DB, error)

Connect 获取db

func ConnectWith

func ConnectWith(dialect gorm.Dialector, option *Option) (*gorm.DB, error)

ConnectWith 通过方言获取db

Types

type ConnectConfig

type ConnectConfig struct {
	Dsn         string // 连接
	Driver      string // 数据库类型
	MaxIdle     int    // 最大空闲连接数
	MaxOpen     int    // 最大连接数
	LogMode     bool   // 是否打印SQL
	MaxLifeTime int    // 连接存活时间
}

ConnectConfig 数据库链接配置

type Option

type Option struct {
	Name       string         // 连接别名
	Config     *ConnectConfig // 连接配置
	Logger     xlog.XLog      // 日志
	LoggerConf *logger.Config // 日志配置
}

Option 连接操作配置

Jump to

Keyboard shortcuts

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