// PostgreSQLConnection func for connection to PostgreSQL database.
PostgreSQLConnection func for connection to PostgreSQL database.
// PostgreSQLConnection func for connection to PostgreSQL database .
func PostgreSQLConnection() (*gorm.DB, error) {
	username := env.Db_user
	password := env.Db_pass
	dbName := env.Db_name
	dbHost := env.Db_host
	dbPort := env.Db_port
	dbUri := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Tehran", dbHost, username, password, dbName, dbPort)
	conn, err := gorm.Open(postgres.Open(dbUri), &gorm.Config{})
	if err != nil {
		return nil, errors.ErrorDatabaseConnection
	}
	return conn, nil
}
func PostgreSQLConnection ( ) ( * gorm . DB , error ) { username := env . Db_user password := env . Db_pass dbName := env . Db_name dbHost := env . Db_host dbPort := env . Db_port dbUri := fmt . Sprintf ( " " , dbHost , username , password , dbName , dbPort ) conn , err := gorm . Open ( postgres . Open ( dbUri ) , & gorm . Config { } ) if err != nil { return nil , errors . ErrorDatabaseConnection } return conn , nil }
PostgreSQLConnection func for connection to PostgreSQL database.
PostgreSQLConnection func for connection to PostgreSQL database .
// Define database connection settings. // conn, err := gorm.Open("postgres", dbUri)