This commit is contained in:
Nama Kamu
2026-09-15 14:47:26 +07:00
parent 27283e041b
commit 8bafff0c98
9 changed files with 108 additions and 13 deletions
+18
View File
@@ -0,0 +1,18 @@
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: %v", err)
}
return conn, nil
}