Skip to content

Commit

Permalink
README: run doc2readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nim65s committed Nov 14, 2023
1 parent dc160db commit 31fc6d5
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,49 +62,47 @@ For an example with using Serde deserialization, please refer to [serde_integrat


```rust
use influxdb::{Client, Timestamp, ReadQuery};
use influxdb::InfluxDbWriteable;
use chrono::{DateTime, Utc};
use influxdb::{Client, Error, InfluxDbWriteable, ReadQuery, Timestamp};

#[tokio::main]
// or #[async_std::main] if you prefer
async fn main() {
async fn main() -> Result<(), Error> {
// Connect to db `test` on `http://localhost:8086`
let client = Client::new("http://localhost:8086", "test");

#[derive(InfluxDbWriteable)]
struct WeatherReading {
time: DateTime<Utc>,
humidity: i32,
#[influxdb(tag)] wind_direction: String,
#[influxdb(tag)]
wind_direction: String,
}

// Let's write some data into a measurement called `weather`
let weather_readings = vec!(
let weather_readings = vec![
WeatherReading {
time: Timestamp::Hours(1).into(),
humidity: 30,
wind_direction: String::from("north"),
}.into_query("weather"),
}
.into_query("weather"),
WeatherReading {
time: Timestamp::Hours(2).into(),
humidity: 40,
wind_direction: String::from("west"),
}.into_query("weather"),
);
}
.into_query("weather"),
];

if let Err(e) = client.query(weather_readings).await {
println!("Error writing result: {e}");
return;
}
client.query(weather_readings).await?;

// Let's see if the data we wrote is there
let read_query = ReadQuery::new("SELECT * FROM weather");

match client.query(read_query).await {
Ok(read_result) => println!("{}", read_result),
Err(e) => println!("Error reading result: {e}"),
}
let read_result = client.query(read_query).await?;
println!("{}", read_result);
Ok(())
}
```

Expand Down Expand Up @@ -168,7 +166,7 @@ To communicate with InfluxDB, you can choose the HTTP backend to be used configu
@ 2020 Gero Gerke and [contributors].

[contributors]: https://github.com/influxdb-rs/influxdb-rust/graphs/contributors
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEG_D2JHss1jsUG6eXkB7MmDoIG9miwB7MgvlwG_-cxCbQ3T7bYWSBgmhpbmZsdXhkYmUwLjcuMQ
[__cargo_doc2readme_dependencies_info]: ggGkYW0BYXSEG64av5CnNoNoGw8lPMr2b0MoG44uU0T70vGSG7osgcbjN7SoYXKEGzTIyZ81-O7yGzBPOAorSf5GGwJWIVB6K85jG41Hl-f5lXJVYWSBgmhpbmZsdXhkYmUwLjcuMQ
[__link0]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CONTRIBUTING.md
[__link1]: https://github.com/influxdb-rs/influxdb-rust/blob/main/CODE_OF_CONDUCT.md
[__link10]: https://curl.se/libcurl/
Expand Down

0 comments on commit 31fc6d5

Please sign in to comment.