main.go 478 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
package main

import (
	"database/sql"
	"fmt"

	_ "github.com/taosdata/driver-go/v2/taosRestful"
)

func main() {
	var taosDSN = "root:taosdata@http(localhost:6041)/"
	taos, err := sql.Open("taosRestful", taosDSN)
	if err != nil {
		fmt.Println("failed to connect TDengine, err:", err)
		return
	}
	fmt.Println("Connected")
	defer taos.Close()
}

D
dingbo 已提交
21
// use
22
// var taosDSN = "root:taosdata@http(localhost:6041)/dbName"
D
dingbo 已提交
23
// if you want to connect a specified database named "dbName".