You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
424 B
20 lines
424 B
package mysqlIniter
|
|
|
|
import (
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
func InitDb(username string, password string, host string, port string, db string) (*gorm.DB, error) {
|
|
Db, err := gorm.Open(
|
|
mysql.Open(
|
|
username+":"+password+"@tcp("+host+":"+port+")/"+db+"?charset=utf8&parseTime=True&loc=Local",
|
|
),
|
|
&gorm.Config{
|
|
PrepareStmt: true,
|
|
SkipDefaultTransaction: true,
|
|
},
|
|
)
|
|
|
|
return Db, err
|
|
}
|
|
|