initial commit
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
func (a *App) initPostgres() {
|
||||
if a.config.postgresURI == "" {
|
||||
return
|
||||
}
|
||||
pool, err := pgxpool.New(a.ctx, a.config.postgresURI)
|
||||
if err != nil {
|
||||
log.Fatalln("failed to connect to postgres:", err)
|
||||
}
|
||||
a.postgres = sqlx.NewDb(stdlib.OpenDBFromPool(pool), "postgres")
|
||||
}
|
||||
Reference in New Issue
Block a user