2021-12-14 13:53:22 +08:00
|
|
|
package bgm
|
2021-12-13 21:39:15 +08:00
|
|
|
|
|
|
|
import (
|
2021-12-14 13:53:22 +08:00
|
|
|
"fmt"
|
2021-12-13 21:39:15 +08:00
|
|
|
"gorm.io/driver/mysql"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
|
|
|
|
2021-12-14 13:53:22 +08:00
|
|
|
func GormMap(dsnPre string) (map[string]*gorm.DB, error) {
|
|
|
|
dsn := fmt.Sprintf("%v/test?charset=utf8mb4&parseTime=True&loc=Local", dsnPre)
|
2021-12-13 21:39:15 +08:00
|
|
|
db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{})
|
|
|
|
return map[string]*gorm.DB{"local": db}, err
|
|
|
|
}
|