This commit is contained in:
Odweta
2026-03-19 10:32:41 +01:00
parent 12def174a4
commit 868594bc3a
6 changed files with 43 additions and 6 deletions
+5 -5
View File
@@ -5,23 +5,23 @@ import (
"fmt"
"os"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
)
var db *pgx.Conn
var db *pgxpool.Pool
func connectDB() {
var err error
connStr := os.Getenv("DB_URL")
if connStr == "" {
panic("DB_URL not set")
}
db, err = pgx.Connect(context.Background(), connStr)
var err error
db, err = pgxpool.New(context.Background(), connStr)
if err != nil {
panic(err)
}
fmt.Println("Connected to PostgreSQL")
fmt.Println("Connected to PostgreSQL (pool)")
}