Browse Source

新增postgresql的Host配置

main
SliverHorn 4 years ago
parent
commit
33c22f5d17
  1. 1
      server/config/config.go
  2. 2
      server/initialize/gorm.go

1
server/config/config.go

@ -44,6 +44,7 @@ type Mysql struct {
}
type Postgresql struct {
Host string `mapstructure:"host" json:"host" yaml:"host"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`

2
server/initialize/gorm.go

@ -82,7 +82,7 @@ func GormMysql() {
// GormPostgreSql 初始化PostgreSql数据库
func GormPostgreSql() {
p := global.GVA_CONFIG.Postgresql
dsn := "user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
dsn := "host="+ p.Host + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
postgresConfig := postgres.Config{
DSN: dsn, // DSN data source name
PreferSimpleProtocol: p.PreferSimpleProtocol, // 禁用隐式 prepared statement

Loading…
Cancel
Save