TDengine/docs/examples/go/connect/restexample/main.go

23 lines
511 B
Go
Raw Normal View History

package main
import (
"database/sql"
"fmt"
2022-08-06 13:56:47 +00:00
"log"
2022-08-01 03:44:40 +00:00
_ "github.com/taosdata/driver-go/v3/taosRestful"
)
func main() {
2024-08-02 06:28:24 +00:00
// use
// var taosDSN = "root:taosdata@http(localhost:6041)/dbName"
// if you want to connect a specified database named "dbName".
var taosDSN = "root:taosdata@http(localhost:6041)/"
taos, err := sql.Open("taosRestful", taosDSN)
if err != nil {
2022-08-06 13:56:47 +00:00
log.Fatalln("failed to connect TDengine, err:", err)
}
2024-08-02 09:12:14 +00:00
fmt.Println("Connected to " + taosDSN + " successfully.")
defer taos.Close()
}