# README
goframework-gorm-mysql
包装gorm-mysql
对象,实现godb
接口。
安装
go get github.com/kordar/goframework-gorm-mysql v1.0.8
使用
- 设置日志等级
logLevel := "info" // error warn info
goframeworkgormmysql.SetDbLogLevel(logLevel)
- 添加实例
// 1、通过配置添加
section := map[string]interface{}{
"host": "127.0.0.1",
"port": 3306,
"user": "root",
"password": "123456",
"db": "test",
"charset": "utf8"
}
if err := goframeworkgormmysql.AddMysqlInstance(key, section); err != nil {
log.Errorf("初始化mysql异常,err=%v", err)
}
// 2、通过dsn添加, user:password@tcp(host:port)/db?params
goframeworkgormmysql.AddMysqlInstanceWithDsn(key, dsn)
# Functions
AddMysqlInstance 添加mysql句柄.
AddMysqlInstances 批量添加mysql句柄.
No description provided by the author
No description provided by the author
HasMysqlInstance mysql句柄是否存在.
No description provided by the author
No description provided by the author
RemoveMysqlInstance 移除mysql句柄.
No description provided by the author
# Structs
No description provided by the author