20 lines
326 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
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
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
}