20 lines
467 B
Go
Raw Normal View History

2021-02-13 02:49:36 +00:00
package main
import (
"context"
"fmt"
"github.com/jackc/pgx/v4/pgxpool"
)
var pool *pgxpool.Pool
func getDbPool() *pgxpool.Pool {
// Setup Database
dbURI := fmt.Sprintf("postgres://%s:%s@%s:%d/fedilogue", settings.Database.Username, settings.Database.Password, settings.Database.Host, settings.Database.Port)
pool, err := pgxpool.Connect(context.Background(), dbURI)
if err != nil {
logFatal.Fatal("Unable to connect to database:", err)
}
return pool
}