Database connection parametrized
parent
1298ceb2b1
commit
be895dbe29
6
.env
6
.env
|
|
@ -1,13 +1,11 @@
|
|||
# Mysql Live
|
||||
|
||||
#Used when creating a JWT. It can be anything.
|
||||
API_SECRET=nyEX8BZ44KqTXeV2
|
||||
API_PORT=8111
|
||||
|
||||
# DB configuration
|
||||
DB_HOST=177.153.50.98
|
||||
DB_DRIVER=mysql
|
||||
DB_DRIVER=postgres
|
||||
DB_USER=pcast
|
||||
DB_PASSWORD=@407Smc837
|
||||
DB_NAME=pcast
|
||||
DB_PORT=3306
|
||||
DB_PORT=5432
|
||||
|
|
@ -3,7 +3,9 @@ package database
|
|||
import (
|
||||
"api/models"
|
||||
"api/utils"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
|
||||
|
|
@ -26,7 +28,8 @@ func ConnectDB() error {
|
|||
}
|
||||
|
||||
// DBURL := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8&parseTime=True&loc=Local", os.Getenv("DB_USER"), os.Getenv("DB_PASSWORD"), os.Getenv("DB_HOST"), os.Getenv("DB_PORT"), os.Getenv("DB_NAME"))
|
||||
DBURL := "postgres://pcast:@407Smc837@177.153.50.98:5432/pcast"
|
||||
//DBURL := "postgres://pcast:@407Smc837@177.153.50.98:5432/pcast"
|
||||
DBURL := fmt.Sprintf("%s://%s:%s@%s:%s/%s", os.Getenv("DB_DRIVER"), os.Getenv("DB_USER"), os.Getenv("DB_PASSWORD"), os.Getenv("DB_HOST"), os.Getenv("DB_PORT"), os.Getenv("DB_NAME"))
|
||||
|
||||
log.Println("Opening connection to database")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue