提交 f0db29ee 编写于 作者: D dingbo

docs: go and rust

上级 590062c4
......@@ -17,7 +17,10 @@ Add dependency to `Cargo.toml`.
```toml title="Cargo.toml"
[dependencies]
libtaos = { version="*", feature=["rest"]}
[dependencies]
libtaos = { version="0.4.5-alpha.0", features=["rest"]}
tokio = { version = "1", features = ["full"]}
anyhow = "*"
```
## Config
......@@ -28,24 +31,21 @@ Run this command in your terminal to save TDengine cloud token as variables:
<TabItem value="bash" label="Bash">
```bash
export TDENGINE_CLOUD_TOKEN="<token>"
export TDENGINE_CLOUD_URL="<url>"
export TDENGINE_CLOUD_DSN="<DSN>"
```
</TabItem>
<TabItem value="cmd" label="CMD">
```bash
set TDENGINE_CLOUD_TOKEN="<token>"
set TDENGINE_CLOUD_URL="<url>"
set TDENGINE_CLOUD_DSN="<DSN>"
```
</TabItem>
<TabItem value="powershell" label="Powershell">
```powershell
$env:TDENGINE_CLOUD_TOKEN="<token>"
$env:TDENGINE_CLOUD_URL="<url>"
$env:TDENGINE_CLOUD_DSN="<DSN>"
```
</TabItem>
......@@ -53,8 +53,7 @@ $env:TDENGINE_CLOUD_URL="<url>"
<!-- exclude -->
:::note
Replace <token\> and <url\> with cloud token and URL.
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".
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".
:::
<!-- exclude-end -->
......
......@@ -16,7 +16,7 @@ func main() {
return
}
defer taos.Close()
rows, err := taos.Query("select server_version()")
rows, err := taos.Query("show databases")
if err != nil {
fmt.Println(err)
return
......
......@@ -7,5 +7,6 @@ edition = "2021"
[dependencies]
libtaos = { version="0.4.5-alpha.0", feature=["rest"]}
libtaos = { version="0.4.5-alpha.0", features=["rest"]}
tokio = { version = "1", features = ["full"]}
anyhow = "*"
use anyhow::Result;
use libtaos::*;
fn main() {
let token = std::env::var("TDENGINE_CLOUD_TOKEN").unwrap();
let url = std::env::var("TDENGINE_CLOUD_URL").unwrap();
let dsn = url + "?token=" + &token;
let taos = TaosCfg::from_dsn(dsn)?;
println!("connected");
#[tokio::main]
async fn main() -> Result<()> {
let dsn = std::env::var("TDENGINE_CLOUD_DSN").unwrap();
let cfg = TaosCfg::from_dsn(dsn)?;
let conn = cfg.connect()?;
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.
先完成此消息的编辑!
想要评论请 注册