Example #1
0
func queryDB(con *client.Client, cmd string) (res []client.Result, err error) {
	q := client.Query{
		Command:  cmd,
		Database: MyDB,
	}
	if response, err := con.Query(q); err == nil {
		if response.Error() != nil {
			return res, response.Error()
		}
		res = response.Results
	}
	return
}
Example #2
0
func writePoints(con *client.Client, data []string) (ret string, err error) {

	bps := client.BatchPoints{
		TextPoints:      data,
		Database:        MyDB,
		RetentionPolicy: "default",
	}
	_, err = con.Write(bps)
	if err != nil {
		log.Fatal(err)
		ret = "write point failse"
	}

	return
}