21 lines
471 B
Go
Raw Normal View History

2021-02-13 02:49:36 +00:00
package main
import (
"os"
2021-02-13 02:49:36 +00:00
"context"
"github.com/jackc/pgx/v4/pgxpool"
"log"
2021-02-13 02:49:36 +00:00
)
var pool *pgxpool.Pool
func getDbPool() *pgxpool.Pool {
// Setup Database
2025-01-24 21:30:25 +00:00
dburl := "postgres://" + os.Getenv("POSTGRES_USER") + ":" +u os.Getenv("POSTGRES_PASSWORD") + "@" + os.Getenv("POSTGRES_HOSTNAME") + "/" + os.Getenv("POSTGRES_DB")
pool, err := pgxpool.Connect(context.Background(), dburl)
2021-02-13 02:49:36 +00:00
if err != nil {
log.Fatal("Unable to connect to database:", err)
2021-02-13 02:49:36 +00:00
}
return pool
}