mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-22 08:40:03 +01:00
19 lines
312 B
Go
19 lines
312 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"log"
|
||
|
|
||
|
"github.com/jackc/pgx/v5"
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
func getPGConn() *pgx.Conn {
|
||
|
url := viper.GetString("postgres.url")
|
||
|
conn, err := pgx.Connect(context.Background(), url)
|
||
|
if err != nil {
|
||
|
log.Panicf("Unable to connect to database: %v\n", err)
|
||
|
}
|
||
|
return conn
|
||
|
}
|