diff --git a/.env b/.env index a164812..1aea1b7 100644 --- a/.env +++ b/.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 \ No newline at end of file +DB_PORT=5432 \ No newline at end of file diff --git a/database/database.go b/database/database.go index b3aba81..4aaf060 100644 --- a/database/database.go +++ b/database/database.go @@ -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")