package database

import (
	"context"
	"github.com/jackc/pgx/v5/pgxpool"
	"log"
)

func Connect(databaseURL string) (*pgxpool.Pool, error) {
	pool, err := pgxpool.New(context.Background(), databaseURL)
	if err != nil {
		return nil, err
	}

	if err := pool.Ping(context.Background()); err != nil {
		return nil, err
	}

	log.Println("Database connected successfully")
	return pool, nil
}
