Open mong0520 opened 4 years ago
There is a NewQuery
function in the client
package: https://github.com/influxdata/influxdb1-client/blob/master/v2/client.go#L471-L473
You could probably just change the example in the readme to execute the query that you wish to run:
func ExampleClient_query() {
c, err := client.NewHTTPClient(client.HTTPConfig{
Addr: "http://localhost:8086",
})
if err != nil {
fmt.Println("Error creating InfluxDB Client: ", err.Error())
}
defer c.Close()
q := client.NewQuery("create database xxx", "", "")
if response, err := c.Query(q); err == nil && response.Error() == nil {
fmt.Println(response.Results)
}
}
I've not tested this, but it might work.
Hope this helps!
I'd like to use this lib to create a new InfluxDB database like the SQL command
create database xxx
. Is it possible to do that?