Added basic admin client
This commit is contained in:
24
db/db.go
Normal file
24
db/db.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user