func ExecuteScriptQuery(rq *http.Request, queriesPath string, script string) ([]byte, error) {
	config.PrestConf.Adapter.SetDatabase(config.PrestConf.PGDatabase)
	sqlPath, err := config.PrestConf.Adapter.GetScript(rq.Method, queriesPath, script)
	if err != nil {
		err = fmt.Errorf("could not get script %s/%s, %+v", queriesPath, script, err)
		return nil, err
	}
	templateData := make(map[string]interface{})
	extractHeaders(rq, templateData)
	extractQueryParameters(rq, templateData)
	sql, values, err := config.PrestConf.Adapter.ParseScript(sqlPath, templateData)
	if err != nil {
		err = fmt.Errorf("could not parse script %s/%s, %+v", queriesPath, script, err)
		return nil, err
	}
	sc := config.PrestConf.Adapter.ExecuteScripts(rq.Method, sql, values)
	if sc.Err() != nil {
		err = fmt.Errorf("could not execute sql %+v, %s", sc.Err(), sql)
		return nil, err
	}
	return sc.Bytes(), nil
}
ExecuteScriptQuery is a function to execute and return result of script query
package controllers
import (
	"fmt"
	"net/http"
	"github.com/gorilla/mux"
	"github.com/prest/prest/config"
)