use DB_DSN database connection string only
This commit is contained in:
parent
359d35fdd2
commit
741f16f88e
1 changed files with 2 additions and 6 deletions
|
|
@ -14,13 +14,9 @@ import (
|
||||||
|
|
||||||
// DBConn returns a postgres connection pool.
|
// DBConn returns a postgres connection pool.
|
||||||
func DBConn() (*bun.DB, error) {
|
func DBConn() (*bun.DB, error) {
|
||||||
viper.SetDefault("db_network", "tcp")
|
viper.SetDefault("db_dsn", "postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable")
|
||||||
viper.SetDefault("db_addr", "localhost:5432")
|
|
||||||
viper.SetDefault("db_user", "postgres")
|
|
||||||
viper.SetDefault("db_password", "postgres")
|
|
||||||
viper.SetDefault("db_database", "postgres")
|
|
||||||
|
|
||||||
dsn := "postgres://" + viper.GetString("db_user") + ":" + viper.GetString("db_password") + "@" + viper.GetString("db_addr") + "/" + viper.GetString("db_database") + "?sslmode=disable"
|
dsn := viper.GetString("db_dsn")
|
||||||
|
|
||||||
sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn)))
|
sqldb := sql.OpenDB(pgdriver.NewConnector(pgdriver.WithDSN(dsn)))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue