Git Product home page Git Product logo

influxdb-rust's Introduction


rust-influxdb

Unofficial InfluxDB Driver for Rust

Build Status Documentation Status Build with Rust Minimum Rust Version

This library is a work in progress. Although we've been using it in production at OpenVelo, we've prioritized features that fit our use cases. This means a feature you might need is not implemented yet or could be handled better.

Pull requests are always welcome. See Contributing and Code of Conduct.

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)
  • Authenticated and Unauthenticated Connections
  • async/await support
  • #[derive(InfluxDbWriteable)] Derive Macro for Writing / Reading into Structs

Planned Features

  • Read Query Builder instead of supplying raw queries

Quickstart

Add the following to your Cargo.toml

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

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

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

#[tokio::main]
async fn main() {
    // 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,
        #[tag] wind_direction: String,
    }

    // Let's write some data into a measurement called `weather`
    let weather_reading = WeatherReading {
        time: Timestamp::Hours(1).into(),
        humidity: 30,
        wind_direction: String::from("north"),
    };

    let write_result = client
        .query(&weather_reading.into_query("weather"))
        .await;
    assert!(write_result.is_ok(), "Write result was not okay");

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

    let read_result = client.query(&read_query).await;
    assert!(read_result.is_ok(), "Read result was not ok");
    println!("{}", read_result.unwrap());
}

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

License

License: MIT

@ 2019 Gero Gerke, All rights reserved.

influxdb-rust's People

Contributors

empty2k12 avatar msrd0 avatar kiriosk avatar gmg137 avatar zjhmale avatar mimetypes avatar mvucenovic avatar neolegends avatar valkum avatar senden9 avatar mario-kr avatar pcpthm avatar

Forkers

mtrnord

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.