about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/db.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/db.go b/src/db.go
index 22ab1a8..300e559 100644
--- a/src/db.go
+++ b/src/db.go
@@ -4,13 +4,22 @@ import (
 	"database/sql"
 	"fmt"
 	"log"
+	"os"
+	"strconv"
 
 	_ "github.com/lib/pq"
 )
 
 // setup the Database
 func setupDatabase() (*sql.DB, error) {
-	connStr := "host=postgresql port=5432 user=postgres dbname=postgres sslmode=disable"
+
+	dbHost := os.Getenv("DBHOST")
+	dbPort, _ := strconv.Atoi(os.Getenv("DBPORT"))
+	dbUser := os.Getenv("DBUSER")
+	dbName := os.Getenv("DBNAME")
+
+	//connStr := "host=postgresql port=5432 user=postgres dbname=postgres sslmode=disable"
+	connStr := fmt.Sprintf("host=%s port=%d user=%s dbname=%s sslmode=disable", dbHost, dbPort, dbUser, dbName)
 
 	// open a connection to the database
 	db, err := sql.Open("postgres", connStr)