fedilogue/db.go
2020-12-29 20:20:02 +00:00

19 lines
442 B
Go

package main
import (
"context"
"fmt"
"github.com/jackc/pgx/pgxpool"
"log"
)
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 {
log.Fatal("Unable to connect to database:", err)
}
return pool
}