2020-11-24 20:36:47 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-13 22:55:35 -05:00
|
|
|
"os"
|
|
|
|
|
2021-02-11 12:34:49 +00:00
|
|
|
"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
|
2021-08-08 23:46:29 +00:00
|
|
|
dburl := os.Getenv("DATABASE_URL")
|
|
|
|
pool, err := pgxpool.Connect(context.Background(), dburl)
|
2020-11-24 20:36:47 -05:00
|
|
|
if err != nil {
|
2022-01-13 22:55:35 -05:00
|
|
|
logFatal("Unable to connect to database:", err)
|
2020-11-24 20:36:47 -05:00
|
|
|
}
|
|
|
|
return pool
|
|
|
|
}
|