|
32 | 32 | //! use influxdb::InfluxDbWriteable; |
33 | 33 | //! use chrono::{DateTime, Utc}; |
34 | 34 | //! |
35 | | -//! # #[tokio::main] |
36 | | -//! # async fn main() { |
37 | | -//! // Connect to db `test` on `http://localhost:8086` |
38 | | -//! let client = Client::new("http://localhost:8086", "test"); |
39 | | -//! |
40 | | -//! #[derive(InfluxDbWriteable)] |
41 | | -//! struct WeatherReading { |
42 | | -//! time: DateTime<Utc>, |
43 | | -//! humidity: i32, |
44 | | -//! #[tag] wind_direction: String, |
| 35 | +//! #[tokio::main] |
| 36 | +//! async fn main() { |
| 37 | +//! // Connect to db `test` on `http://localhost:8086` |
| 38 | +//! let client = Client::new("http://localhost:8086", "test"); |
| 39 | +//! |
| 40 | +//! #[derive(InfluxDbWriteable)] |
| 41 | +//! struct WeatherReading { |
| 42 | +//! time: DateTime<Utc>, |
| 43 | +//! humidity: i32, |
| 44 | +//! #[tag] wind_direction: String, |
| 45 | +//! } |
| 46 | +//! |
| 47 | +//! // Let's write some data into a measurement called `weather` |
| 48 | +//! let weather_reading = WeatherReading { |
| 49 | +//! time: Timestamp::Hours(1).into(), |
| 50 | +//! humidity: 30, |
| 51 | +//! wind_direction: String::from("north"), |
| 52 | +//! }; |
| 53 | +//! |
| 54 | +//! let write_result = client |
| 55 | +//! .query(&weather_reading.into_query("weather")) |
| 56 | +//! .await; |
| 57 | +//! assert!(write_result.is_ok(), "Write result was not okay"); |
| 58 | +//! |
| 59 | +//! // Let's see if the data we wrote is there |
| 60 | +//! let read_query = Query::raw_read_query("SELECT * FROM weather"); |
| 61 | +//! |
| 62 | +//! let read_result = client.query(&read_query).await; |
| 63 | +//! assert!(read_result.is_ok(), "Read result was not ok"); |
| 64 | +//! println!("{}", read_result.unwrap()); |
45 | 65 | //! } |
46 | | -//! |
47 | | -//! // Let's write some data into a measurement called `weather` |
48 | | -//! let weather_reading = WeatherReading { |
49 | | -//! time: Timestamp::Hours(1).into(), |
50 | | -//! humidity: 30, |
51 | | -//! wind_direction: String::from("north"), |
52 | | -//! }; |
53 | | -//! |
54 | | -//! let write_result = client |
55 | | -//! .query(&weather_reading.into_query("weather")) |
56 | | -//! .await; |
57 | | -//! assert!(write_result.is_ok(), "Write result was not okay"); |
58 | | -//! |
59 | | -//! // Let's see if the data we wrote is there |
60 | | -//! let read_query = Query::raw_read_query("SELECT * FROM weather"); |
61 | | -//! |
62 | | -//! let read_result = client.query(&read_query).await; |
63 | | -//! assert!(read_result.is_ok(), "Read result was not ok"); |
64 | | -//! println!("{}", read_result.unwrap()); |
65 | 66 | //! ``` |
66 | 67 | //! |
67 | 68 | //! For further examples, check out the Integration Tests in `tests/integration_tests.rs` |
|
0 commit comments