This commit is contained in:
Yovan
2026-09-15 14:34:41 +07:00
parent b2f9a5c3c1
commit 2ec9fbd933
9 changed files with 119 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
package database
import (
"context"
"fmt"
"os"
"github.com/jackc/pgx/v5"
)
func Connect() (*pgx.Conn, error) {
conn, err := pgx.Connect(context.Background(), os.Getenv("DATABASE_URL"))
if err != nil {
return nil, fmt.Errorf("unable to connect to database: %w", err)
}
return conn, nil
}