Upgraded Go version and the version of all dependencies. Fixed som more bugs.
This commit is contained in:
@@ -3,11 +3,11 @@ package db
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"os"
|
||||
)
|
||||
|
||||
var pool *pgxpool.Pool
|
||||
var pool *pgx.Conn
|
||||
|
||||
func InitDB(host string, port int, user string, password string, dbname string) {
|
||||
|
||||
@@ -18,7 +18,7 @@ func InitDB(host string, port int, user string, password string, dbname string)
|
||||
fmt.Println(psqlInfo)
|
||||
|
||||
var err error
|
||||
pool, err = pgxpool.Connect(context.Background(), psqlInfo)
|
||||
pool, err = pgx.Connect(context.Background(), psqlInfo)
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err)
|
||||
os.Exit(1)
|
||||
@@ -30,11 +30,15 @@ func InitDB(host string, port int, user string, password string, dbname string)
|
||||
_, _ = fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
Testf()
|
||||
fmt.Println(success)
|
||||
}
|
||||
|
||||
func CloseDb() {
|
||||
pool.Close()
|
||||
err := pool.Close(context.Background())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func Testf() {
|
||||
|
||||
Reference in New Issue
Block a user