init module
This commit is contained in:
parent
ccb7843d48
commit
f4da943b5d
|
@ -15,13 +15,15 @@ var (
|
|||
sqlxClient *sqlx.DB
|
||||
)
|
||||
|
||||
// Connect to postgres database
|
||||
// Connect to postgresql database
|
||||
func Connect(host, user, password, dbname, port, sslmode string) error {
|
||||
// Connect string
|
||||
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=%s TimeZone=UTC",
|
||||
host, user, password, dbname, port, sslmode,
|
||||
)
|
||||
|
||||
// TODO: write case for SSL mode
|
||||
|
||||
db, err := sqlx.Connect("postgres", dsn)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
|
|
Loading…
Reference in New Issue