diff --git a/docs-en/05-develop/01-connect/01-python.md b/docs-en/05-develop/01-connect/01-python.md index c137df32f66079fbce9ba6ecc4e414157b9fb765..48202137e82b6da9a0debe7640f2cdfa9ab8b6ac 100644 --- a/docs-en/05-develop/01-connect/01-python.md +++ b/docs-en/05-develop/01-connect/01-python.md @@ -15,16 +15,15 @@ You'll need to have Python3 installed. ## Config -Run this command in your terminal to save your URL and token as variables: +Run this command in your terminal to save TDengine cloud token as variables: ```bash -export TDENGINE_CLOUD_URL= -export TDENGINE_CLOUD_TOKEN= +export TDENGINE_TOKEN= ``` :::note -You should replace above placeholders as real values. To obtain these values, please log in TDengine Cloud and switch to "Connector" section. +To obtain cloud token, please log in TDengine Cloud and switch to "Connector" section. ::: @@ -37,8 +36,8 @@ Copy code bellow to your editor and run it with `python3` command. import taosrest import os -url = os.environ["TDENGINE_CLOUD_URL"] -token = os.environ["TDENGINE_CLOUD_TOKEN"] +token = os.environ["TDENGINE_TOKEN"] +url = "https://cloud.tdengine.com" conn = taosrest.connect(url=url, token=token) ``` diff --git a/docs-en/05-develop/01-connect/02-java.md b/docs-en/05-develop/01-connect/02-java.md index d17dfddaf7795baf245fb22548931e397a304c72..f4cd583af409ceb09d2c7c01019c87f19f06b3d0 100644 --- a/docs-en/05-develop/01-connect/02-java.md +++ b/docs-en/05-develop/01-connect/02-java.md @@ -25,35 +25,29 @@ dependencies { ## Config -Run this command in your terminal to save your url and token as variables: +Run this command in your terminal to save TDengine cloud token as variables: ```bash -export TDENGINE_CLOUD_URL= -export TDENGINE_CLOUD_TOKEN= +export TDENGINE_TOKEN= ``` - -:::note -You should replace above placeholders as real values. To obtain these values, please log in TDengine Cloud and switch to "Connector" section. - -::: - - ## Connect -Code bellow get URL and token from environment variables first and then create a `RestfulConnection` object, witch is a standard JDBC Connection object. ```java -import com.taosdata.jdbc.rs.RestfulConnection; import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; public class ConnectCloudExample { - public static void main(String[] args) throws Exception { - String url = System.getenv("TDENGINE_CLOUD_URL"); - String token = System.getenv("TDENGINE_CLOUD_TOKEN"); - Connection conn = new RestfulConnection(url, token); + public static void main(String[] args) throws SQLException { + String token = System.getenv("TDENGINE_TOKEN"); + String jdbcUrl = "jdbc:TAOS-RS://cloud.taosdata.com:8085?usessl=true&token=" + token; + Connection conn = DriverManager.getConnection(jdbcUrl); + System.out.println("Connected"); + conn.close(); } } ``` diff --git a/docs-en/05-develop/01-connect/03-go.md b/docs-en/05-develop/01-connect/03-go.md new file mode 100644 index 0000000000000000000000000000000000000000..f1cd8118ca5e514a732d0e53b84eb7678ec4ed2b --- /dev/null +++ b/docs-en/05-develop/01-connect/03-go.md @@ -0,0 +1,50 @@ +--- +sidebar_label: Go +title: Connect with Go Connector +--- + +## Add Dependency + +add `driver-go` dependency in `go.mod` . + +``` title="go.mod" +module goexample + +go 1.17 + +require github.com/taosdata/driver-go/v2 develop +``` + +## Config + +Run this command in your terminal to save TDengine cloud token as variables: + +```bash +export TDENGINE_TOKEN= +``` + +## Connect + +```go +package main + +import ( + "database/sql" + "fmt" + "os" + + _ "github.com/taosdata/driver-go/v2/taosRestful" +) + +func main() { + host := os.Getenv("TDENGIN_TOKEN") + taosDSN := "https://cloud.taosdata.com?token=" + token + taos, err := sql.Open("taosRestful", taosDSN) + if err != nil { + fmt.Println("failed to connect TDengine, err:", err) + return + } + fmt.Println("Connected") + defer taos.Close() +} +``` \ No newline at end of file diff --git a/docs-en/05-develop/01-connect/04-rust.md b/docs-en/05-develop/01-connect/04-rust.md new file mode 100644 index 0000000000000000000000000000000000000000..44d3a1fab4c5c69ea63a70adeb5a1e3da9566307 --- /dev/null +++ b/docs-en/05-develop/01-connect/04-rust.md @@ -0,0 +1,31 @@ +--- +sidebar_label: Rust +title: Connect with Rust Connector +--- + +## Add Dependency + + +``` title="Cargo.toml" + +``` + +## Config + +Run this command in your terminal to save TDengine cloud token as variables: + +```bash +export TDENGINE_TOKEN= +``` + +## Connect + +```go +use libtaos::*; + +fn main() { + let token = std::env::var("TDENGINE_TOKEN").unwrap(); + let dsn = format!("https://cloud:tdengine.com?token={}", token); + let taos = Taos::from_dsn(dsn.as_str())?; +} +``` \ No newline at end of file diff --git a/docs-en/05-develop/01-connect/05-node.md b/docs-en/05-develop/01-connect/05-node.md new file mode 100644 index 0000000000000000000000000000000000000000..4d3808f8e4aa09b41d3e34fa2b0df0ab327c207c --- /dev/null +++ b/docs-en/05-develop/01-connect/05-node.md @@ -0,0 +1,32 @@ +--- +sidebar_label: Node.js +title: Connect with Node.js Connector +--- + +## Install Connector + + + +## Config + +Run this command in your terminal to save TDengine cloud token as variables: + +```bash +export TDENGINE_TOKEN= +``` + + +## Connect + + +```python +const { options, connect } = require("td2.0-rest-connector"); + +async function test() { + options.url = "https://cloud.tdengine.com"; + options.token = process.env.TDENGIN_TOKEN; + let conn = connect(options); +} +test(); +``` +