func Request(query string) ([]byte, error) { client := &http.Client{} r, _ := http.NewRequest("POST", dbHost, bytes.NewBufferString(query)) resp, err := client.Do(r) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } if resp.StatusCode != 200 { return nil, errors.New(string(body)) } return body, nil}
package main
import ( "io/ioutil" "net/http" "errors" "bytes" "fmt")
const dbHost = "http://127.0.0.1:8123/"
func Request(query string) ([]byte, error) { client := &http.Client{} r, _ := http.NewRequest("POST", dbHost, bytes.NewBufferString(query)) resp, err := client.Do(r) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } if resp.StatusCode != 200 { return nil, errors.New(string(body)) } return body, nil}
func main() { if res, err := Request("SELECT sipHash64('hello');"); err == nil { fmt.Print(string(res)) }}INSERT INTO MyTable ( Col1, Col2, Col3) VALUES
( 1410025, 97650, 1),( 1101713, 8450, 1),( 1413381, 5200, 1),( 1401211, 34650, 1),( 1410412, 1950, 1);