add database name in go test

This commit is contained in:
Artur 2021-08-26 09:44:10 +00:00
parent a7d982198c
commit 933b2e07c2

View File

@ -24,19 +24,19 @@ func compress(data io.Reader) io.Reader {
} }
func main() { func main() {
database := os.Getenv("CLICKHOUSE_DATABASE")
p, err := url.Parse("http://localhost:8123/") p, err := url.Parse("http://localhost:8123/")
if err != nil { if err != nil {
panic(err) panic(err)
} }
q := p.Query() q := p.Query()
q.Set("query", "INSERT INTO graphite FORMAT RowBinary") q.Set("query", "INSERT INTO "+database+".graphite FORMAT RowBinary")
p.RawQuery = q.Encode() p.RawQuery = q.Encode()
queryUrl := p.String() queryUrl := p.String()
var req *http.Request var req *http.Request
req, err = http.NewRequest("POST", queryUrl, compress(os.Stdin)) req, err = http.NewRequest("POST", queryUrl, compress(os.Stdin))
req.Header.Add("Content-Encoding", "gzip") req.Header.Add("Content-Encoding", "gzip")