The `/api/v2/query` API endpoint and associated tooling, such as the `influx` CLI and InfluxDB v2 client libraries, **aren’t** supported in {{% product-name %}}.
- **InfluxDB v3 client libraries**: Use language-specific (Python, Go, etc.) clients to execute queries in your terminal or custom code.
- **Grafana**: Use the [FlightSQL Data Source plugin](https://grafana.com/grafana/plugins/influxdata-flightsql-datasource/), to query, connect, and visualize data.
For this example, use the following query to select all the data written to the
**get-started** database between
{{% influxdb/custom-timestamps-span %}}
**2022-01-01T08:00:00Z** and **2022-01-01T20:00:00Z**.
{{% /influxdb/custom-timestamps-span %}}
{{% influxdb/custom-timestamps %}}
```sql
SELECT
*
FROM
home
WHERE
time >= '2022-01-01T08:00:00Z'
AND time <= '2022-01-01T20:00:00Z'
```
{{% /influxdb/custom-timestamps %}}
{{% note %}}
Some examples in this getting started tutorial assume your InfluxDB
3. Install the CLI package (already installed in the [Write data section](/influxdb/clustered/get-started/write/?t=Python#write-line-protocol-to-influxdb)).
{{<reqtype="key"text="Already installed in the [Write data section](/influxdb/clustered/get-started/write/?t=Python#write-line-protocol-to-influxdb)"color="magenta">}}
- [`influxdb3-python`{{< req text="\* " color="magenta" >}}](https://github.com/InfluxCommunity/influxdb3-python): Provides the InfluxDB `influxdb_client_3` Python client library module and also installs the [`pyarrow` package](https://arrow.apache.org/docs/python/index.html) for working with Arrow data returned from queries.
- [`pandas`](https://pandas.pydata.org/): Provides `pandas` functions, modules, and data structures for analyzing and manipulating data.
- [`tabulate`](https://pypi.org/project/tabulate/): Provides the `tabulate` function for formatting tabular data. pandas requires this module for formatting data as Markdown.
{{% expand "<spanclass='req'>Important</span>: If using **Windows**, specify the **Windows** certificate path" %}}
When instantiating the client, Python looks for SSL/TLS certificate authority (CA) certificates for verifying the server's authenticity.
If using a non-POSIX-compliant operating system (such as Windows), you need to specify a certificate bundle path that Python can access on your system.
The following example shows how to use the [Python `certifi` package](https://certifiio.readthedocs.io/en/latest/) and client library options to provide a bundle of trusted certificates to the Python Flight client:
1. In your terminal, install the Python `certifi` package.
```sh
pip install certifi
```
2. In your Python code, import `certifi` and call the `certifi.where()` method to retrieve the certificate path.
3. When instantiating the client, pass the `flight_client_options.tls_root_certs=<ROOT_CERT_PATH>` option with the certificate path--for example:
2. Defines a `Query()` function that does the following:
1. Instantiates `influx.Client` with InfluxDB credentials.
- **`Host`**: your {{% product-name omit=" Clustered" %}} cluster URL
- **`Database`**: The name of your {{% product-name %}} database
- **`Token`**: a [database token](/influxdb/clustered/admin/tokens/) with read permission on the specified database.
_Store this in a secret store or environment variable to avoid exposing the raw token string._
2. Defines a deferred function to close the client after execution.
3. Defines a string variable for the SQL query.
4. Calls the `influxdb3.Client.Query(sql string)` method and passes the SQL string to query InfluxDB.
`Query(sql string)` method returns an `iterator` for data in the response stream.
5. Iterates over rows, formats the timestamp as an [RFC3339 timestamp](/influxdb/clustered/reference/glossary/#rfc3339-timestamp), and prints the data in table format to stdout.
3. In your editor, open the `main.go` file you created in the
[Write data section](/influxdb/clustered/get-started/write/?t=Go#write-line-protocol-to-influxdb) and insert code to call the `Query()` function--for example:
```go
package main
func main() {
WriteLineProtocol()
Query()
}
```
4. In your terminal, enter the following command to install the necessary packages, build the module, and run the program:
go mod tidy && go build && go run influxdb_go_client
```
The program executes the `main()` function that writes the data and prints the query results to the console.
{{% /influxdb/custom-timestamps %}}
<!------------------------------ END GO CONTENT ------------------------------->
{{% /tab-content %}}
{{% tab-content %}}
{{% influxdb/custom-timestamps %}}
<!---------------------------- BEGIN NODE.JS CONTENT --------------------------->
_This tutorial assumes you installed Node.js and npm, and created an `influxdb_js_client` npm project as described in the [Write data section](/influxdb/clustered/get-started/write/?t=Nodejs)._
1. In your terminal or editor, change to the `influxdb_js_client` directory you created in the
[Write data section](/influxdb/clustered/get-started/write/?t=Nodejs).
2. If you haven't already, install the `@influxdata/influxdb3-client` JavaScript client library as a dependency to your project:
3. Create a file named `query.mjs`. The `.mjs` extension tells the Node.js interpreter that you're using [ES6 module syntax](https://nodejs.org/api/esm.html#modules-ecmascript-modules).
4. Inside of `query.mjs`, enter the following sample code:
```js
// query.mjs
import {InfluxDBClient} from '@influxdata/influxdb3-client'
import {tableFromArrays} from 'apache-arrow';
/**
* Set InfluxDB credentials.
*/
const host = "https://{{<influxdb/host>}}";
const database = 'get-started';
/**
* INFLUX_TOKEN is an environment variable you assigned to your
* database READ token value.
*/
const token = process.env.INFLUX_TOKEN;
/**
* Query InfluxDB with SQL using the JavaScript client library.
2. Calls `new InfluxDBClient()` and passes a `ClientOptions` object to instantiate a client configured
with InfluxDB credentials.
- **`host`**: your {{% product-name omit=" Clustered" %}} cluster URL
- **`token`**: a [database token](/influxdb/clustered/admin/tokens/) with read permission on the database you want to query.
_Store this in a secret store or environment variable to avoid exposing the raw token string._
3. Defines a string variable (`sql`) for the SQL query.
4. Defines an object (`data`) with column names for keys and array values for storing row data.
5. Calls the `InfluxDBClient.query()` method with the following arguments:
- **`sql`**: the query to execute
- **`database`**: the name of the {{% product-name %}} database to query
`query()` returns a stream of row vectors.
6. Iterates over rows and adds the column data to the arrays in `data`.
7. Passes `data` to the Arrow `tableFromArrays()` function to format the arrays as a table, and then passes the result to the `console.table()` method to output a highlighted table in the terminal.
5. Inside of `index.mjs` (created in the [Write data section](/influxdb/clustered/get-started/write/?t=Nodejs)), enter the following sample code to import the modules and call the functions:
```js
// index.mjs
import { writeLineProtocol } from "./write.mjs";
import { querySQL } from "./query.mjs";
/**
* Execute the client functions.
*/
async function main() {
/** Write line protocol data to InfluxDB. */
await writeLineProtocol();
/** Query data from InfluxDB using SQL. */
await querySQL();
}
main();
```
9. In your terminal, execute `index.mjs` to write to and query {{% product-name %}}:
2. Defines a `Query` class with a `QuerySQL()` method that does the following:
1. Calls the `new InfluxDBClient()` constructor to instantiate a client configured
with InfluxDB credentials.
- **`host`**: your {{% product-name omit=" Clustered" %}} cluster URL.
- **`database`**: the name of the {{% product-name %}} database to query
- **`token`**: a [database token](/influxdb/clustered/admin/tokens/) with read permission on the specified database.
_Store this in a secret store or environment variable to avoid exposing the raw token string._
2. Defines a string variable for the SQL query.
3. Calls the `InfluxDBClient.Query()` method to send the query request with the SQL string.
`Query()` returns batches of rows from the response stream as a two-dimensional array--an array of rows in which each row is an array of values.
4. Iterates over rows and prints the data in table format to stdout.
3. In your editor, open the `Program.cs` file you created in the
[Write data section](/influxdb/clustered/get-started/write/?t=C%23#write-line-protocol-to-influxdb) and insert code to call the `Query()` function--for example:
```c#
// Program.cs
using System;
using System.Threading.Tasks;
namespace InfluxDBv3;
public class Program
{
public static async Task Main()
{
await Write.WriteLineProtocol();
await Query.QuerySQL();
}
}
```
4. To build and execute the program and query your {{% product-name omit=" Clustered" %}} cluster,
<!------------------------------ END C# CONTENT ------------------------------->
{{% /tab-content %}}
{{% tab-content %}}
<!------------------------------ BEGIN JAVA CONTENT ------------------------------->
{{% influxdb/custom-timestamps %}}
_This tutorial assumes using Maven version 3.9, Java version >= 15, and an `influxdb_java_client` Maven project created in the [Write data section](/influxdb/clustered/get-started/write/?t=Java)._
1. In your terminal or editor, change to the `influxdb_java_client` directory you created in the
[Write data section](/influxdb/clustered/get-started/write/?t=Java).
2. Inside of the `src/main/java/com/influxdbv3` directory, create a new file named `Query.java`.
3. In `Query.java`, enter the following sample code:
```java
// Query.java
package com.influxdbv3;
import com.influxdb.v3.client.InfluxDBClient;
import java.util.stream.Stream;
/**
* Queries an InfluxDB database using the Java client
* library.
**/
public final class Query {
private Query() {
//not called
}
/**
*@throws Exception
*/
public static void querySQL() throws Exception {
/**
* Query using SQL.
*/
/** Set InfluxDB credentials. **/
final String host = "https://{{<influxdb/host>}}";
final String database = "get-started";
/** INFLUX_TOKEN is an environment variable you assigned to your
* database READ token value.
**/
final char[] token = (System.getenv("INFLUX_TOKEN")).
5. Set the `--add-opens=java.base/java.nio=ALL-UNNAMED` Java option for your environment.
The Apache Arrow Flight library requires this setting for access to the [java.nio API package](https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/nio/package-summary.html).
For example, enter the following command in your terminal: