first commit
This commit is contained in:
16
internal/db/postgres.go
Normal file
16
internal/db/postgres.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func Connect(host, port, user, password, dbname, sslmode string) (*sql.DB, error) {
|
||||
dsn := fmt.Sprintf(
|
||||
"host=%s port=%s user=%s password=%s dbname=%s sslmode=%s",
|
||||
host, port, user, password, dbname, sslmode,
|
||||
)
|
||||
return sql.Open("postgres", dsn)
|
||||
}
|
||||
Reference in New Issue
Block a user