---
title: Use the influxdb3 CLI to query data
description: Use the influxdb3 query command to query data in InfluxDB 3 Core with SQL.
url: https://docs.influxdata.com/influxdb3/core/query-data/execute-queries/influxdb3-cli/
estimated_tokens: 1271
product: InfluxDB 3 Core
version: core
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb3/core/query-data/execute-queries/influxdb3-cli/
date: '2025-05-15T13:46:17-05:00'
lastmod: '2025-05-15T13:46:17-05:00'
---

Use the [`influxdb3 query` command](/influxdb3/core/reference/cli/influxdb3/query/)to query data in InfluxDB 3 Core with SQL or InfluxQL.

Provide the following with your command:

* **Authorization token**: Your InfluxDB 3 Core [admin token](/influxdb3/core/admin/tokens/admin)

  with read permissions on the database.
  Provide this using one of the following:

  * `--token` command option
  * `INFLUXDB3_AUTH_TOKEN` environment variable

* **Database name**: The name of the database to query.
  Provide this using one of the following:

  * `-d`, `--database` command option
  * `INFLUXDB3_DATABASE_NAME` environment variable

* **Query language** *(Optional)*: The query language of the query.
  Use the `-l`, `--language` option to specify one of the following query languages:

  * `sql` *(default)*
  * `influxql`

* **Query**: SQL or InfluxQL query to execute. Provide the query in one of the
  following ways:

  * a string
  * the `--file` option and the path to a file that contains the query
  * from stdin

#### SQL ####

#### string ####

```bash
influxdb3 query \
  --token AUTH_TOKEN \
  --database DATABASE_NAME \
  "SELECT * FROM home"
```

```bash
influxdb3 query \
  --token AUTH_TOKEN \
  --database DATABASE_NAME \
  --file ./query.sql
```

```bash
cat ./query.sql | influxdb3 query --token AUTH_TOKEN --database DATABASE_NAME
```

#### string ####

```bash
influxdb3 query \
  --token AUTH_TOKEN \
  --language influxql \
  --database DATABASE_NAME \
  "SELECT * FROM home"
```

```bash
influxdb3 query \
  --token AUTH_TOKEN \
  --language influxql \
  --file ./query.influxql
```

```bash
cat ./query.influxql | influxdb3 query \
  --token AUTH_TOKEN \
  --language influxql \
  --database DATABASE_NAME
```

In the examples above and below, replace the following:

* `DATABASE_NAME`:
  Name of the database to query

## Output format

The `influxdb3 query` command supports the following output formats:

* `pretty` *(default)*
* `json`
* `jsonl`
* `csv`
* `parquet` *(must [output to a file](#output-query-results-to-a-parquet-file))*

Use the `--format` flag to specify the output format:

```sh
influxdb3 query \
  --token AUTH_TOKEN \
  --database DATABASE_NAME \
  --format json \
  "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' LIMIT 5"
```

[](#view-example-pretty-formatted-results)

View example pretty-formatted results

```
+----+------+-------------+------+---------------------+
| co | hum  | room        | temp | time                |
+----+------+-------------+------+---------------------+
| 0  | 35.9 | Living Room | 21.1 | 2022-01-01T08:00:00 |
| 0  | 35.9 | Kitchen     | 21.0 | 2022-01-01T08:00:00 |
| 0  | 35.9 | Living Room | 21.4 | 2022-01-01T09:00:00 |
| 0  | 36.2 | Kitchen     | 23.0 | 2022-01-01T09:00:00 |
| 0  | 36.0 | Living Room | 21.8 | 2022-01-01T10:00:00 |
+----+------+-------------+------+---------------------+
```

[](#view-example-json-formatted-results)

View example JSON-formatted results

```json
[{"co":0,"hum":35.9,"room":"Living Room","temp":21.1,"time":"2022-01-01T08:00:00"},{"co":0,"hum":35.9,"room":"Kitchen","temp":21.0,"time":"2022-01-01T08:00:00"},{"co":0,"hum":35.9,"room":"Living Room","temp":21.4,"time":"2022-01-01T09:00:00"},{"co":0,"hum":36.2,"room":"Kitchen","temp":23.0,"time":"2022-01-01T09:00:00"},{"co":0,"hum":36.0,"room":"Living Room","temp":21.8,"time":"2022-01-01T10:00:00"}]
```

[](#view-example-json-line-formatted-results)

View example JSON-line-formatted results

```jsonl
{"co":0,"hum":35.9,"room":"Living Room","temp":21.1,"time":"2022-01-01T08:00:00"}
{"co":0,"hum":35.9,"room":"Kitchen","temp":21.0,"time":"2022-01-01T08:00:00"}
{"co":0,"hum":35.9,"room":"Living Room","temp":21.4,"time":"2022-01-01T09:00:00"}
{"co":0,"hum":36.2,"room":"Kitchen","temp":23.0,"time":"2022-01-01T09:00:00"}
{"co":0,"hum":36.0,"room":"Living Room","temp":21.8,"time":"2022-01-01T10:00:00"}
```

[](#view-example-csv-formatted-results)

View example CSV-formatted results

```csv
co,hum,room,temp,time
0,35.9,Living Room,21.1,2022-01-01T08:00:00
0,35.9,Kitchen,21.0,2022-01-01T08:00:00
0,35.9,Living Room,21.4,2022-01-01T09:00:00
0,36.2,Kitchen,23.0,2022-01-01T09:00:00
0,36.0,Living Room,21.8,2022-01-01T10:00:00
```

## Output query results to a Parquet file

To output query results to a Parquet file, provide the following options with
the `influxdb3 query` command:

* `--format`: `parquet`
* `-o`, `--output`: the filepath to the Parquet file to store results in

```sh
influxdb3 query \
  --token AUTH_TOKEN \
  --database DATABASE_NAME \
  --format parquet \
  --output path/to/results.parquet \
  "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' LIMIT 5"
```

#### Related

* [influxdb3 query](/influxdb3/core/reference/cli/influxdb3/query/)
* [SQL reference documentation](/influxdb3/core/reference/sql/)
* [InfluxQL reference documentation](/influxdb3/core/reference/influxql/)

[query](/influxdb3/core/tags/query/)[sql](/influxdb3/core/tags/sql/)[influxql](/influxdb3/core/tags/influxql/)[influxdb3](/influxdb3/core/tags/influxdb3/)[CLI](/influxdb3/core/tags/cli/)
