2020-11-24 20:36:47 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-12-12 05:50:43 +00:00
|
|
|
"fmt"
|
2020-12-17 04:23:25 +00:00
|
|
|
"log"
|
2020-12-17 18:26:55 +00:00
|
|
|
"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
|
|
|
|
}
|