Added basic admin client

This commit is contained in:
2022-08-06 16:25:03 +02:00
parent 95ea2190fa
commit 03ad7d60cc
5 changed files with 102 additions and 13 deletions

24
db/db.go Normal file
View File

@@ -0,0 +1,24 @@
package db
import (
"context"
"github.com/jackc/pgx/v4/pgxpool"
"os"
)
var Db *pgxpool.Pool
func Connect(connStr string) error {
if connStr == "" {
connStr = os.Getenv("QDDNS_DB")
}
if connStr == "" {
connStr = "postgresql:///pdns"
}
conn, err := pgxpool.Connect(context.Background(), connStr)
if err != nil {
return err
}
Db = conn
return nil
}