package database
import (
	"database/sql"
	"fmt"
	_ "github.com/lib/pq"

)



func ConnectDB(host string, port int, user string, password string, dbname string) (*sql.DB, error) {

	psql := fmt.Sprintf("host=%s port=%d user=%s "+ "password=%s dbname=%s sslmode=disable", host, port, user, password, dbname)

	db, err := sql.Open("postgres", psql)
	if err != nil {
		panic(err)
	}
	return db, nil
}

func CloseDB(db *sql.DB) error {
	err := db.Close()
	if err != nil {
		return err
	}

	return nil
}
