1 Star 0 Fork 0

dabolau / lakaiService

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
mysql.go 547 Bytes
Copy Edit Raw Blame History
dabolau authored 2021-11-09 16:59 . 第一次提交
package database
import (
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
// var (
// // DB 数据库
// DB *gorm.DB
// )
// OpenMySQL 数据库连接
// https://gorm.io/zh_CN/docs/connecting_to_the_database.html
func OpenMySQL() (err error) {
// 数据来源名称
// 获取详情 https://github.com/go-sql-driver/mysql#dsn-data-source-name
dsn := "root:@tcp(localhost:3306)/lakai?charset=utf8mb4&parseTime=True&loc=Local"
// 数据库连接
DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
if err != nil {
return err
}
return nil
}
Go
1
https://gitee.com/dabolau/lakaiService.git
git@gitee.com:dabolau/lakaiService.git
dabolau
lakaiService
lakaiService
53e17f936a9f

Search

53164aa7 5694891 3bd8fe86 5694891