Files
server/internal/database/database.go
T
AmirGhost11 ff300a5e84
Build / test-and-build (scribblers-linux-x64, ubuntu-latest) (push) Has been cancelled
Build / test-and-build (scribblers-macos-x64, macos-latest) (push) Has been cancelled
Build / test-and-build (scribblers-x64.exe, windows-latest) (push) Has been cancelled
feat: Initialized Project
2026-05-09 09:36:38 +03:30

28 lines
508 B
Go

package database
import (
"context"
"log"
"github.com/jackc/pgx/v5/pgxpool"
)
var Pool *pgxpool.Pool
func ConnectToDB(connection_string string) {
var err error
Pool, err = pgxpool.New(context.Background(), connection_string)
if err != nil {
log.Fatalf("Unable to create connection pool: %v", err)
}
// Test the connection
err = Pool.Ping(context.Background())
if err != nil {
log.Fatalf("Unable to ping the database: %v", err)
}
log.Println("Successfully connected to the database")
}