21 lines
385 B
Go
21 lines
385 B
Go
package logic
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gorm.io/driver/mysql"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type Mysql struct {
|
|
Host, Username, Password string
|
|
Port int
|
|
Database, Parameters string
|
|
}
|
|
|
|
func (this *Mysql) DSN() gorm.Dialector {
|
|
return mysql.Open(fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?%s",
|
|
this.Username, this.Password, this.Host, this.Port, this.Database, this.Parameters,
|
|
))
|
|
}
|