mysql

package
v0.0.0-...-03e5372 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB() error

CloseDB 关闭数据库连接

func Init

func Init(config *Config)

Init 初始化配置

func InitDB

func InitDB() (*gorm.DB, error)

InitDB 创建数据库实例,仅在第一次调用时执行初始化

func NewDB

func NewDB() (*gorm.DB, error)

GetDB 获取数据库实例,若未初始化则自动调用 NewDB

Types

type Config

type Config struct {
	ConnString      string
	ConnMaxLifetime int64 // ConnMaxLifetime 最大连接时间,单位:小时
	MaxIdleConns    int
	MaxOpenConns    int
	InitTable       bool
}

Jump to

Keyboard shortcuts

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