Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

README.md

Connecting Python 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 uv

  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 the Python script main.py as needed.

    • Change the connection arguments in db_kwargs.
      • 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 cursor.execute().
  3. Run the Python script:

    uv run main.py

Clean up

Stop the Docker container running InfluxDB:

docker stop influxdb