Giter Site home page Giter Site logo

juanangel / influxdb-rust Goto Github PK

View Code? Open in Web Editor NEW

This project forked from influxdb-rs/influxdb-rust

0.0 0.0 0.0 313 KB

Rust Client for the InfluxDB Time Series Database

Home Page: https://crates.io/crates/influxdb

License: MIT License

Rust 99.78% Dockerfile 0.22%

influxdb-rust's Introduction


rust-influxdb

Unofficial InfluxDB Driver for Rust

Build Status Coverage Report Documentation Status Build with Rust Minimum Rust Version: 1.65

Pull requests are always welcome. See Contributing and Code of Conduct. For a list of past changes, see CHANGELOG.md.

Currently Supported Features

  • Reading and writing to InfluxDB
  • Optional Serde support for deserialization
  • Running multiple queries in one request (e.g. SELECT * FROM weather_berlin; SELECT * FROM weather_london)
  • Writing single or multiple measurements in one request (e.g. WriteQuery or Vec<WriteQuery> argument)
  • Authenticated and unauthenticated connections
  • async/await support
  • #[derive(InfluxDbWriteable)] derive macro for writing / reading into structs
  • GROUP BY support
  • Tokio and async-std support (see example below) or available backends
  • Swappable HTTP backends (see below)

Quickstart

Add the following to your Cargo.toml

influxdb = { version = "0.7.2", features = ["derive"] }

For an example with using Serde deserialization, please refer to serde_integration

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

#[tokio::main]
// or #[async_std::main] if you prefer
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,
    }

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

    client.query(weather_readings).await?;

    // Read back all records
    let read_query = ReadQuery::new("SELECT * FROM weather");

    let read_result = client.query(read_query).await?;
    println!("{}", read_result);
    Ok(())
}

For further examples, check out the integration tests in tests/integration_tests.rs in the repository.

Choice of HTTP backend

To communicate with InfluxDB, you can choose the HTTP backend to be used configuring the appropriate feature. We recommend sticking with the default reqwest-based client, unless you really need async-std compatibility.

  • hyper (through reqwest, used by default), with rustls

    influxdb = { version = "0.7.2", features = ["derive"] }
  • hyper (through reqwest), with native TLS (OpenSSL)

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls"] }
  • hyper (through reqwest), with vendored native TLS (OpenSSL)

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "reqwest-client-native-tls-vendored"] }
  • hyper (through surf), use this if you need tokio 0.2 compatibility

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "hyper-client"] }
  • curl, using libcurl

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "curl-client"] }
  • async-h1 with native TLS (OpenSSL)

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client"] }
  • async-h1 with rustls

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "h1-client-rustls"] }
  • WebAssembly’s window.fetch, via web-sys and wasm-bindgen

    influxdb = { version = "0.7.2", default-features = false, features = ["derive", "serde", "wasm-client"] }

License

License: MIT

@ 2020-2024 Gero Gerke, msrd0 and contributors.

influxdb-rust's People

Contributors

empty2k12 avatar msrd0 avatar juanangel avatar dependabot[bot] avatar jenoch avatar safarimonkey avatar bytedream avatar kiriosk avatar ctrlaltf24 avatar robert-steiner avatar neolegends avatar sunng87 avatar rcastill avatar valkum avatar senden9 avatar thetasinner avatar bogdad avatar mario-kr avatar pcpthm avatar sparky8251 avatar mvucenovic avatar mcronce avatar mimetypes avatar jaredwolff avatar zjhmale avatar nim65s avatar blasrodri avatar sdether avatar amonin7 avatar 0xdmtri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.