Build out structure

This commit is contained in:
Dustin Pianalto
2020-09-29 19:36:45 -08:00
parent 0258e0910f
commit 76e448f5a3
11 changed files with 165 additions and 12 deletions
+21
View File
@@ -0,0 +1,21 @@
package postgres
import (
"database/sql"
"fmt"
_ "github.com/lib/pq"
)
func ConnectDatabase(dbConnString string) *sql.DB {
db, err := sql.Open("postgres", dbConnString)
if err != nil {
panic(fmt.Sprintf("Can't connect to the database. %v", err))
} else {
fmt.Println("Database Connected.")
}
db.SetMaxOpenConns(75) // The RDS instance has a max of 75 open connections
db.SetMaxIdleConns(5)
db.SetConnMaxLifetime(300)
return db
}