// NewDB attempts to discover and connect to a postgres database
NewDB attempts to discover and connect to a postgres database
// NewDB attempts to discover and connect to a postgres database
func NewDB() (*gorm.DB, error) {
	dataSourceName := "postgres://" + dBUser + ":" + dBPass + "@" + dBURL + "/" + dBName + "?sslmode=disable"
	db, err := gorm.Open("postgres", dataSourceName)
	if err != nil {
		log.Println("couldn't get a db connection!")
		return nil, err
	}
	if err := db.DB().Ping(); err != nil {
		log.Println("Failed to keep db connection alive")
		return nil, err
	}
	return db, nil
}
func NewDB ( ) ( * gorm . DB , error ) { dataSourceName := " " + dBUser + " " + dBPass + " " + dBURL + " " + dBName + " " db , err := gorm . Open ( " " , dataSourceName ) if err != nil { log . Println ( " " ) return nil , err } if err := db . DB ( ) . Ping ( ) ; err != nil { log . Println ( " " ) return nil , err } return db , nil }
NewDB attempts to discover and connect to a postgres database
NewDB attempts to discover and connect to a postgres database