Skip to content

Commit 231944e

Browse files
committed
WIP gs query guides
1 parent 9dc847b commit 231944e

File tree

1 file changed

+53
-13
lines changed
  • content/shared/influxdb3-get-started

1 file changed

+53
-13
lines changed

content/shared/influxdb3-get-started/query.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,59 @@ the [update on InfluxDB 3 Core’s 72-hour limitation](https://www.influxdata.co
1313
> [!Note]
1414
> Flux, the language introduced in InfluxDB v2, is **not** supported in InfluxDB 3.
1515
16-
The quickest way to get started querying is to use the `influxdb3` CLI
17-
(which uses the Flight SQL API over HTTP2).
18-
19-
The `query` subcommand includes options to help ensure that the right database is queried with the correct permissions. Only the `--database` option is required, but depending on your specific setup, you may need to pass other options, such as host, port, and token.
20-
21-
| Option | Description | Required |
22-
|---------|-------------|--------------|
23-
| `--host` | The host URL of the server [default: `http://127.0.0.1:8181`] to query | No |
24-
| `--database` | The name of the database to operate on | Yes |
25-
| `--token` | The authentication token for the {{% product-name %}} server | No |
26-
| `--language` | The query language of the provided query string [default: `sql`] [possible values: `sql`, `influxql`] | No |
27-
| `--format` | The format in which to output the query [default: `pretty`] [possible values: `pretty`, `json`, `jsonl`, `csv`, `parquet`] | No |
28-
| `--output` | The path to output data to | No |
16+
The quickly to get started querying, use the
17+
[`influxdb3 query` command](/influxdb3/version/reference/cli/influxdb3/query/)
18+
and provide the following:
19+
20+
- `-H`, `--host`: The host URL of the server _(default is `http://127.0.0.1:8181`)_
21+
- `-d`, `--database`: _({{% req %}})_ The name of the database to query
22+
- `-l`, `--language`: The query language of the provided query string
23+
- `sql` _(default)_
24+
- `influxql`
25+
- SQL or InfluxQL query as a string
26+
27+
> [!Important]
28+
> If the `INFLUXDB3_AUTH_TOKEN` environment variable defined in
29+
> [Set up {{% product-name %}}](/influxdb3/version/get-started/setup/#set-your-token-for-authorization)
30+
> is no longer set, reset the environment variable or provide your token using
31+
> the `-t, --token` option in your command.
32+
33+
To query the home sensor sample data you wrote in
34+
[Write data to {{% product-name %}}](/influxdb3/version/get-started/write/#write-data-using-the-cli),
35+
run the following command:
36+
37+
{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN" %}}
38+
39+
{{< code-tabs-wrapper >}}
40+
{{% code-tabs %}}
41+
[SQL](#)
42+
[InfluxQL](#)
43+
{{% /code-tabs %}}
44+
{{% code-tab-content %}}
45+
46+
<!-- pytest.mark.skip -->
47+
```bash
48+
influxdb3 query \
49+
--database DATABASE_NAME \
50+
"SELECT * FROM home WHERE time >= now() - INTERVAL '7 days' ORDER BY time"
51+
```
52+
{{% /code-tab-content %}}
53+
{{% code-tab-content %}}
54+
<!-- pytest.mark.skip -->
55+
```bash
56+
influxdb3 query \
57+
--database DATABASE_NAME \
58+
--language influxql \
59+
"SELECT * FROM home WHERE time >= now() - 7d"
60+
```
61+
{{% /code-tab-content %}}
62+
{{< /code-tabs-wrapper >}}
63+
64+
{{% /code-placeholders %}}
65+
66+
Replace {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}
67+
with the name of the database to query.
68+
2969

3070
#### Example: query `“SHOW TABLES”` on the `servers` database:
3171

0 commit comments

Comments
 (0)