mirror of
https://github.com/aykhans/movier.git
synced 2025-04-17 04:13:12 +00:00
17 lines
286 B
Go
17 lines
286 B
Go
package postgresql
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5"
|
|
)
|
|
|
|
func NewDB(dbURL string) (*pgx.Conn, error) {
|
|
conn, err := pgx.Connect(context.Background(), dbURL)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("failed to connect to database: %w", err)
|
|
}
|
|
return conn, nil
|
|
}
|