building database connection string from config file
This commit is contained in:
parent
10013323ef
commit
9e2af34c15
@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/jackc/pgx/pgxpool"
|
"github.com/jackc/pgx/pgxpool"
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
||||||
@ -51,7 +52,8 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
|||||||
|
|
||||||
func get_db_pool() (*pgxpool.Pool) {
|
func get_db_pool() (*pgxpool.Pool) {
|
||||||
// Setup Database
|
// Setup Database
|
||||||
pool, err := pgxpool.Connect(context.Background(), "postgres://postgres@127.0.0.1/fedilogue")
|
db_uri := 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(), db_uri)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Unable to connect to database:", err)
|
log.Fatal("Unable to connect to database:", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user