21 lines
335 B
Go
Raw Normal View History

2020-11-24 20:36:47 -05:00
package main
import (
"context"
"os"
"github.com/jackc/pgx/v4/pgxpool"
2020-11-24 20:36:47 -05:00
)
2021-02-13 02:48:11 +00:00
var pool *pgxpool.Pool
2020-12-17 04:23:25 +00:00
func getDbPool() *pgxpool.Pool {
2020-11-24 20:36:47 -05:00
// Setup Database
dburl := os.Getenv("DATABASE_URL")
pool, err := pgxpool.Connect(context.Background(), dburl)
2020-11-24 20:36:47 -05:00
if err != nil {
logFatal("Unable to connect to database:", err)
2020-11-24 20:36:47 -05:00
}
return pool
}