云数据库 GAUSSDB NOSQL-通过Go语言连接实例:使用非SSL方式连接实例的示例代码

时间:2023-11-10 12:13:26

使用非SSL方式连接实例的示例代码

package main

import (
    "fmt"
    _ "github.com/influxdata/influxdb1-client" // this is important because of the bug in go mod
    client "github.com/influxdata/influxdb1-client/v2"
)

func main(){
    c, err := client.NewHTTPClient(client.HTTPConfig{
        Addr: "http://ip:port",
        Username: "******",
        Password: "******",
    })
    if err != nil {
        fmt.Println("Error creating InfluxDB Client: ", err.Error())
    }
    q := client.NewQuery("select * from cpu","db0","ns")
    if response, err := c.Query(q); err == nil && response.Error() == nil {
        fmt.Println("the result is: ",response.Results)
    } 
}
support.huaweicloud.com/productdesc-nosql/nosql_09_0073.html