ws and pruner done!!!
This commit is contained in:
parent
c5cc245e25
commit
74add408e6
34 changed files with 1455 additions and 221 deletions
22
util/db_connector.go
Normal file
22
util/db_connector.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
)
|
||||
|
||||
func GetDBConnection(addr string) (*sql.DB, error) {
|
||||
db, err := sql.Open("pgx", addr)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("db failed to open, %w", err)
|
||||
}
|
||||
|
||||
err = db.Ping()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("db failed to ping, %w", err)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue