Files

21 lines
385 B
Go
Raw Normal View History

2021-09-28 11:47:19 +08:00
package logic
import (
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type Mysql struct {
2021-12-28 10:38:02 +08:00
Host, Username, Password string
Port int
Database, Parameters string
2021-09-28 11:47:19 +08:00
}
func (this *Mysql) DSN() gorm.Dialector {
return mysql.Open(fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?%s",
2021-12-28 10:38:02 +08:00
this.Username, this.Password, this.Host, this.Port, this.Database, this.Parameters,
2021-09-28 11:47:19 +08:00
))
}