{"id":13529630,"url":"https://github.com/wenj91/taos-driver","last_synced_at":"2026-01-12T12:27:00.379Z","repository":{"id":38097309,"uuid":"432880643","full_name":"wenj91/taos-driver","owner":"wenj91","description":"为TDengine提供了GO驱动程序,基于TDengine的RESTFul api重构的驱动版本，纯golang实现","archived":false,"fork":false,"pushed_at":"2022-06-10T10:24:00.000Z","size":60,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T16:35:08.978Z","etag":null,"topics":["driver","golang","pure-golang","tdengine"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wenj91.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-29T02:27:37.000Z","updated_at":"2022-06-02T11:02:22.000Z","dependencies_parsed_at":"2022-08-18T08:21:40.982Z","dependency_job_id":null,"html_url":"https://github.com/wenj91/taos-driver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wenj91/taos-driver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenj91%2Ftaos-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenj91%2Ftaos-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenj91%2Ftaos-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenj91%2Ftaos-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wenj91","download_url":"https://codeload.github.com/wenj91/taos-driver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wenj91%2Ftaos-driver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["driver","golang","pure-golang","tdengine"],"created_at":"2024-08-01T07:00:38.012Z","updated_at":"2026-01-12T12:27:00.361Z","avatar_url":"https://github.com/wenj91.png","language":"Go","funding_links":[],"categories":["Connector"],"sub_categories":[],"readme":"# Go Connector for TDengine\n\n[![Build Status](https://cloud.drone.io/api/badges/taosdata/driver-go/status.svg)](https://cloud.drone.io/taosdata/driver-go)\n\n\n为TDengine提供了GO驱动程序 `taosSql` [taos-driver]，实现了GO语言的内置数据库操作接口 `database/sql/driver`。\n\n## 提示\n\n`github.com/wenj91/taos-driver` 是基于TDengine的RESTFul api重构的驱动版本，纯golang实现。\n\n## 安装\n\n对新建项目，建议使用Go 1.14+，并使用 GO Modules 方式进行管理。\n\n```sh\ngo mod init taos-demo\n```\n\n引入taosSql：\n\n```go\nimport (\n    \"database/sql\"\n    _ \"github.com/wenj91/taos-driver\"\n)\n```\n\n使用`go mod`方式管理依赖包：\n\n```sh\ngo mod tidy\n```\n\n或通过`go get`直接下载安装：\n\n```sh\ngo get github.com/wenj91/taos-driver\n```\n\n## 用法\n\n### `database/sql` 标准接口\n\nTDengine Go 连接器提供 database/sql 标准接口，使用方法简单示例如下：\n\n```go\npackage main\n\nimport (\n\t\"database/sql\"\n\t\"fmt\"\n\t\"time\"\n\n\t_ \"github.com/wenj91/taos-driver\"\n)\n\nfunc main() {\n\tvar taosuri = \"root:taosdata@/http(localhost:6041)/test\"\n\ttaos, err := sql.Open(\"taosSql\", taosuri)\n\tif err != nil {\n\t\tfmt.Println(\"failed to connect TDengine, err:\", err)\n\t\treturn\n\t}\n\tdefer taos.Close()\n\ttaos.Exec(\"create database if not exists test\")\n\ttaos.Exec(\"use test\")\n\ttaos.Exec(\"create table if not exists tb1 (ts timestamp, a int)\")\n\t_, err = taos.Exec(\"insert into tb1 values(now, 0)(now+1s,1)(now+2s,2)(now+3s,3)\")\n\tif err != nil {\n\t\tfmt.Println(\"failed to insert, err:\", err)\n\t\treturn\n\t}\n\trows, err := taos.Query(\"select * from tb1\")\n\tif err != nil {\n\t\tfmt.Println(\"failed to select from table, err:\", err)\n\t\treturn\n\t}\n\n\tdefer rows.Close()\n\tfor rows.Next() {\n\t\tvar r struct {\n\t\t\tts time.Time\n\t\t\ta  int\n\t\t}\n\t\terr := rows.Scan(\u0026r.ts, \u0026r.a)\n\t\tif err != nil {\n\t\t\tfmt.Println(\"scan error:\\n\", err)\n\t\t\treturn\n\t\t}\n\t\tfmt.Println(r.ts, r.a)\n\t}\n}\n```\n\n常用API列表：\n\n- `sql.Open(DRIVER_NAME string, dataSourceName string) *DB`\n\n  该API用来创建`database/sql` DB对象，类型为`*DB`，DRIVER_NAME设置为字符串`taosSql`,\n  dataSourceName设置为字符串`user:password@/tcp(host:port)/dbname`，对应于TDengine的高可用机制，可以使用 `user:password@/cfg/dbname`\n  来使用`/etc/taos/taos.cfg`中的多EP配置。\n\n  **注意**： 该API成功创建的时候，并没有做权限等检查，只有在真正执行Query或者Exec的时候才能真正的去创建连接，并同时检查user/password/host/port是不是合法。\n\n- `func (db *DB) Exec(query string, args ...interface{}) (Result, error)`\n\n  sql.Open内置的方法，用来执行非查询相关SQL，如`create`, `alter`等。\n\n- `func (db *DB) Query(query string, args ...interface{}) (*Rows, error)`\n\n  sql.Open内置的方法，用来执行查询语句。\n\n- `func (db *DB) Close() error`\n\n  sql.Open内置的方法，关闭DB对象。\n\n## 导航\n\ntaos-driver: [https://github.com/wenj91/taos-driver](https://github.com/wenj91/taos-driver)\n\ndriver-go: [https://github.com/taosdata/driver-go](https://github.com/taosdata/driver-go)\n\nTDengine: [https://github.com/taosdata/TDengine](https://github.com/taosdata/TDengine)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenj91%2Ftaos-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwenj91%2Ftaos-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwenj91%2Ftaos-driver/lists"}