--- title: InfluxDB description: Available to teams and users on all plans noIndex: false noContent: false coverImage: g890zy2wQGiGh2NahdVa --- Use Deepnote to query time series data in InfluxDB v2 with Python and Flux. ### 1. Download and import the InfluxDB example Download the [InfluxDB example notebook](https://github.com/deepnote/deepnote/blob/main/examples/query-influxdb-from-deepnote.ipynb) and follow the [Jupyter notebook import steps](/docs/importing-and-exporting-jupyter-notebooks) to add it to your project. After importing it, connect the notebook to your InfluxDB instance. ### 2. Connect to InfluxDB from Deepnote To connect to InfluxDB, you need an API token, your organization name, and your InfluxDB instance URL. **Create an InfluxDB token** [Create an InfluxDB token](https://docs.influxdata.com/influxdb/cloud/admin/tokens/create-token/) with read access to the bucket you want to query. #### Update the token in the notebook Change the variable `INFLUXDB_TOKEN` to the token you made in the previous step. #### Update the organization and URL details in the notebook Set `INFLUXDB_ORG` to your [organization name](https://docs.influxdata.com/influxdb/v2/admin/organizations/view-orgs/). Change the variable `INFLUXDB_URL` to the URL where your InfluxDB instance is located. ### 3. Query InfluxDB from Deepnote The template creates an InfluxDB Python `client`. Use `client.query_api()` to run a Flux query and return a pandas DataFrame. This example queries [InfluxDB's air sensor sample data](https://docs.influxdata.com/influxdb/v2/reference/sample-data/#air-sensor-sample-data). ```python import pandas as pd query_api = client.query_api() query = """import "influxdata/influxdb/sample" sample.data(set: "airSensor") |> filter(fn: (r) => r._field == "temperature") |> range(start: -45m) |> aggregateWindow(every: 1m, fn: mean)""" result = query_api.query_data_frame(query) if isinstance(result, list): df = pd.concat(result, ignore_index=True) if result else pd.DataFrame() else: df = result df ``` The client returns a DataFrame or, when result tables have different schemas, a list of DataFrames. The code combines that list into one DataFrame for display. ### What's next? Share your results with your team or [publish your notebook as an app](/docs/creating-apps). For more connection and query options, see the [InfluxDB Python client documentation](https://github.com/influxdata/influxdb-client-python).