---
title: Use the influxdb3 CLI to query data
description: Use the influxdb3 query command to query data in InfluxDB 3 Enterprise with SQL.
url: https://docs.influxdata.com/influxdb3/enterprise/query-data/execute-queries/influxdb3-cli/
estimated_tokens: 5113
product: InfluxDB 3 Enterprise
version: enterprise
---

# Use the influxdb3 CLI to query data

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

Provide the following with your command:

-   **Authorization token**: Your InfluxDB 3 Enterprise [admin token](/influxdb3/enterprise/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

<!-- Tabbed content: Select one of the following options -->

**SQL:**

<!-- Tabbed content: Select one of the following options -->

**string:**

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

**file:**

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

**stdin:**

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

<!-- End tabbed content -->

**InfluxQL:**

<!-- Tabbed content: Select one of the following options -->

**string:**

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

**file:**

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

**stdin:**

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

<!-- End tabbed content -->

<!-- End tabbed content -->

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/enterprise/reference/cli/influxdb3/query/)
-   [SQL reference documentation](/influxdb3/enterprise/reference/sql/)
-   [InfluxQL reference documentation](/influxdb3/enterprise/reference/influxql/)

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