提交 f0db29ee 编写于 作者: D dingbo

docs: go and rust

上级 590062c4
...@@ -17,7 +17,10 @@ Add dependency to `Cargo.toml`. ...@@ -17,7 +17,10 @@ Add dependency to `Cargo.toml`.
```toml title="Cargo.toml" ```toml title="Cargo.toml"
[dependencies] [dependencies]
libtaos = { version="*", feature=["rest"]} [dependencies]
libtaos = { version="0.4.5-alpha.0", features=["rest"]}
tokio = { version = "1", features = ["full"]}
anyhow = "*"
``` ```
## Config ## Config
...@@ -28,24 +31,21 @@ Run this command in your terminal to save TDengine cloud token as variables: ...@@ -28,24 +31,21 @@ Run this command in your terminal to save TDengine cloud token as variables:
<TabItem value="bash" label="Bash"> <TabItem value="bash" label="Bash">
```bash ```bash
export TDENGINE_CLOUD_TOKEN="<token>" export TDENGINE_CLOUD_DSN="<DSN>"
export TDENGINE_CLOUD_URL="<url>"
``` ```
</TabItem> </TabItem>
<TabItem value="cmd" label="CMD"> <TabItem value="cmd" label="CMD">
```bash ```bash
set TDENGINE_CLOUD_TOKEN="<token>" set TDENGINE_CLOUD_DSN="<DSN>"
set TDENGINE_CLOUD_URL="<url>"
``` ```
</TabItem> </TabItem>
<TabItem value="powershell" label="Powershell"> <TabItem value="powershell" label="Powershell">
```powershell ```powershell
$env:TDENGINE_CLOUD_TOKEN="<token>" $env:TDENGINE_CLOUD_DSN="<DSN>"
$env:TDENGINE_CLOUD_URL="<url>"
``` ```
</TabItem> </TabItem>
...@@ -53,8 +53,7 @@ $env:TDENGINE_CLOUD_URL="<url>" ...@@ -53,8 +53,7 @@ $env:TDENGINE_CLOUD_URL="<url>"
<!-- exclude --> <!-- exclude -->
:::note :::note
Replace <token\> and <url\> with cloud token and URL. Replace <DSN\> with real TDengine cloud DSN. To obtain the real value, please log in [TDengine Cloud](https://cloud.tdengine.com) and click "Connector" and then select "Rust".
To obtain the value of cloud token and URL, please log in [TDengine Cloud](https://cloud.tdengine.com) and click "Connector" and then select "Rust".
::: :::
<!-- exclude-end --> <!-- exclude-end -->
......
...@@ -16,7 +16,7 @@ func main() { ...@@ -16,7 +16,7 @@ func main() {
return return
} }
defer taos.Close() defer taos.Close()
rows, err := taos.Query("select server_version()") rows, err := taos.Query("show databases")
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return return
......
...@@ -7,5 +7,6 @@ edition = "2021" ...@@ -7,5 +7,6 @@ edition = "2021"
[dependencies] [dependencies]
libtaos = { version="0.4.5-alpha.0", feature=["rest"]} libtaos = { version="0.4.5-alpha.0", features=["rest"]}
tokio = { version = "1", features = ["full"]} tokio = { version = "1", features = ["full"]}
anyhow = "*"
use anyhow::Result;
use libtaos::*; use libtaos::*;
fn main() { #[tokio::main]
let token = std::env::var("TDENGINE_CLOUD_TOKEN").unwrap(); async fn main() -> Result<()> {
let url = std::env::var("TDENGINE_CLOUD_URL").unwrap(); let dsn = std::env::var("TDENGINE_CLOUD_DSN").unwrap();
let dsn = url + "?token=" + &token; let cfg = TaosCfg::from_dsn(dsn)?;
let taos = TaosCfg::from_dsn(dsn)?; let conn = cfg.connect()?;
println!("connected"); let _ = conn.query("show databases").await?;
println!("Connected");
Ok(())
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册