Skip to content

InfluxDB IOx

Brett Buddin edited this page Jan 12, 2023 · 3 revisions

Connecting

InfluxDB IOx requires bucket-name or bucket-id to be presented as gRPC metadata in Flight SQL requests. When creating a FlightSQLClient directly this means providing these keys in the metadata dictionary. When dialing via SQLAlchemy's DSN you will add bucket-name/bucket-id as additional query parameters.

Directly with Client

from flightsql import FlightSQLClient

client = FlightSQLClient(
  host="",
  token="INFLUXDBTOKEN",
  metadata={"bucket-name": "_tasks"},
)

DB API 2 Interface

Same as Directly with Client, but passing the client into connect.

from flightsql import FlightSQLClient, connect

client = FlightSQLClient(
  host="",
  token="INFLUXDBTOKEN",
  metadata={"bucket-name": "_tasks"},
)
conn = connect(client)

SQLAlchemy with the DataFusion Dialect

import flightsql.sqlalchemy
from sqlalchemy.engine import create_engine

engine = create_engine("datafusion+flightsql://...:443?token=INFLUXDBTOKEN&bucket-name=_tasks")
Clone this wiki locally