fedilogue/db.go

19 lines
442 B
Go
Raw Normal View History

2020-11-24 20:36:47 -05:00
package main
import (
"context"
"fmt"
2020-12-17 04:23:25 +00:00
"log"
"github.com/jackc/pgx/pgxpool"
2020-11-24 20:36:47 -05:00
)
2020-12-17 04:23:25 +00:00
func getDbPool() *pgxpool.Pool {
2020-11-24 20:36:47 -05:00
// Setup Database
2020-12-17 04:23:25 +00:00
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)
2020-11-24 20:36:47 -05:00
if err != nil {
log.Fatal("Unable to connect to database:", err)
}
return pool
}