Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Connecting Rust and InfluxDB with ADBC

Instructions

This example uses InfluxDB, a time series database that supports Arrow Flight SQL.

Tip

If you already have an InfluxDB instance running, skip the steps to set up and clean up InfluxDB.

Prerequisites

  1. Install Rust

  2. Install dbc

Set up InfluxDB

  1. Install Docker

  2. Start an InfluxDB instance:

    docker run -d --rm --name influxdb -p 8181:8181 influxdb:3-core influxdb3
  3. Create an authorization token:

    docker exec -it influxdb influxdb3 create token --admin

Connect to InfluxDB

  1. Install the Flight SQL ADBC driver:

    dbc install flightsql
  2. Customize src/main.rs as needed.

    • Change the connection arguments in opts.
      • OptionDatabase::Uri is the URI of your InfluxDB instance. The host and port will depend on your installation.
      • adbc.flight.sql.authorization_header is the authorization header used for requests. Replace YOUR_AUTH_TOKEN with your InfluxDB authorization token.
      • adbc.flight.sql.rpc.call_header.database is the name of your InfluxDB database.
    • If you changed which database you're connecting to, also change the SQL SELECT statement in statement.set_sql_query().
  3. Run the Rust program:

    cargo run

Clean up

Stop the Docker container running InfluxDB:

docker stop influxdb