Skip to content

Commit 4c04f21

Browse files
authored
Merge pull request #5731 from influxdata/jstirnaman/issue5159
fix(v3): Python flight_client_options param, update list examples
2 parents e85951d + 2147c9e commit 4c04f21

File tree

3 files changed

+85
-48
lines changed
  • content/influxdb
    • cloud-dedicated/reference/client-libraries/v3
    • cloud-serverless/reference/client-libraries/v3
    • clustered/reference/client-libraries/v3

3 files changed

+85
-48
lines changed

content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,45 @@ menu:
88
parent: v3 client libraries
99
identifier: influxdb3-python
1010
influxdb/cloud-dedicated/tags: [Flight API, python, gRPC, SQL, client libraries]
11-
metadata: [influxdb3-python v0.5.0]
11+
metadata: [influxdb3-python v0.10.0]
1212
weight: 201
1313
aliases:
1414
- /influxdb/cloud-dedicated/reference/client-libraries/v3/pyinflux3/
1515
related:
1616
- /influxdb/cloud-dedicated/query-data/execute-queries/troubleshoot/
17-
list_code_example: >
18-
17+
list_code_example: |
18+
19+
<!--Hide setup
20+
```python
21+
import os
22+
from influxdb_client_3 import InfluxDBClient3
23+
24+
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
25+
database=f"DATABASE_NAME", token=f"DATABASE_TOKEN")
26+
```
27+
-->
28+
<!--pytest-codeblocks:cont-->
29+
1930
```python
2031
# Example: Write and query data
21-
22-
# Write sensor data into influxDB
23-
24-
# and retrieve data from the last 90 days for analysis.
25-
26-
27-
# Write sensor data in batches from a CSV file
28-
client.write_file(file='./data/home-sensor-data.csv', timestamp_column='time',
29-
tag_columns=["room"])
30-
31-
# Execute a query and retrieve data formatted as a PyArrow Table
32-
table = client.query(
32+
33+
# Write sensor data in batches from a CSV file to a database
34+
client.write_file(file='./data/home-sensor-data.csv',
35+
timestamp_column='time',
36+
tag_columns=["room"])
37+
38+
# Execute a query and retrieve data from the last 90 days
39+
table = client.query(
3340
'''SELECT *
3441
FROM home
3542
WHERE time >= now() - INTERVAL '90 days'
3643
ORDER BY time''')
37-
38-
# This script assumes the client object is correctly configured with your database name, token, and host URL.
39-
# After the script runs, the table variable contains the data formatted as a PyArrow table.
4044
41-
```
42-
45+
# This script assumes the client object is correctly configured
46+
# with your database name, token, and host URL.
47+
# After the script runs, the table variable contains the data
48+
# formatted as a PyArrow table.
49+
```
4350
---
4451

4552
The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python)
@@ -947,7 +954,7 @@ fh.close()
947954
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
948955
database=f"DATABASE_NAME",
949956
token=f"DATABASE_TOKEN",
950-
fco=flight_client_options(tls_root_certs=cert))
957+
flight_client_options=flight_client_options(tls_root_certs=cert))
951958
```
952959

953960
{{% /code-placeholders %}}

content/influxdb/cloud-serverless/reference/client-libraries/v3/python.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,45 @@ menu:
99
identifier: influxdb3-python
1010
influxdb/cloud-serverless/tags:
1111
[Flight API, python, gRPC, SQL, client libraries]
12-
metadata: [influxdb3-python v0.5.0]
12+
metadata: [influxdb3-python v0.10.0]
1313
weight: 201
1414
aliases:
1515
- /influxdb/cloud-serverless/reference/client-libraries/v3/pyinflux3/
1616
related:
1717
- /influxdb/cloud-serverless/query-data/execute-queries/troubleshoot/
18+
list_code_example: |
19+
20+
<!--Hide setup
21+
```python
22+
import os
23+
from influxdb_client_3 import InfluxDBClient3
24+
25+
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
26+
database=f"BUCKET_NAME", token=f"API_TOKEN")
27+
```
28+
-->
29+
<!--pytest-codeblocks:cont-->
30+
31+
```python
32+
# Example: Write and query data
33+
34+
# Write sensor data in batches from a CSV file to a database
35+
client.write_file(file='./data/home-sensor-data.csv',
36+
timestamp_column='time',
37+
tag_columns=["room"])
38+
39+
# Execute a query and retrieve data from the last 90 days
40+
table = client.query(
41+
'''SELECT *
42+
FROM home
43+
WHERE time >= now() - INTERVAL '90 days'
44+
ORDER BY time''')
45+
46+
# This script assumes the client object is correctly configured
47+
# with your bucket name, token, and host URL.
48+
# After the script runs, the table variable contains the data
49+
# formatted as a PyArrow table.
50+
```
1851
---
1952

2053
The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python/)
@@ -939,7 +972,7 @@ fh.close()
939972
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
940973
database=f"BUCKET_NAME",
941974
token=f"API_TOKEN",
942-
fco=flight_client_options(tls_root_certs=cert))
975+
flight_client_options=flight_client_options(tls_root_certs=cert))
943976
```
944977

945978
{{% /code-placeholders %}}

content/influxdb/clustered/reference/client-libraries/v3/python.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,45 @@ menu:
88
parent: v3 client libraries
99
identifier: influxdb3-python
1010
influxdb/clustered/tags: [Flight API, python, gRPC, SQL, client libraries]
11-
metadata: [influxdb3-python v0.5.0]
11+
metadata: [influxdb3-python v0.10.0]
1212
weight: 201
1313
aliases:
1414
- /influxdb/clustered/reference/client-libraries/v3/pyinflux3/
1515
related:
1616
- /influxdb/clustered/query-data/execute-queries/troubleshoot/
1717
list_code_example: |
18-
<!-- Import for tests and hide from users.
18+
19+
<!--Hide setup
1920
```python
2021
import os
22+
from influxdb_client_3 import InfluxDBClient3
23+
24+
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
25+
database=f"DATABASE_NAME", token=f"DATABASE_TOKEN")
2126
```
2227
-->
2328
<!--pytest-codeblocks:cont-->
24-
```python
25-
from influxdb_client_3 import(InfluxDBClient3,
26-
WriteOptions,
27-
write_client_options)
28-
29-
# Instantiate batch writing options for the client
30-
31-
write_options = WriteOptions()
32-
wco = write_client_options(write_options=write_options)
33-
34-
# Instantiate an InfluxDB v3 client
3529
36-
with InfluxDBClient3(host=f"{{< influxdb/host >}}",
37-
database=f"DATABASE_NAME",
38-
token=f"DATABASE_TOKEN",
39-
write_client_options=wco) as client:
40-
41-
# Write data in batches
42-
client.write_file(file='./data/home-sensor-data.csv', timestamp_column='time',
43-
tag_columns=["room"])
30+
```python
31+
# Example: Write and query data
4432
45-
# Execute a query and retrieve data formatted as a PyArrow Table
33+
# Write sensor data in batches from a CSV file to a database
34+
client.write_file(file='./data/home-sensor-data.csv',
35+
timestamp_column='time',
36+
tag_columns=["room"])
4637
47-
table = client.query(
38+
# Execute a query and retrieve data from the last 90 days
39+
table = client.query(
4840
'''SELECT *
4941
FROM home
5042
WHERE time >= now() - INTERVAL '90 days'
5143
ORDER BY time''')
52-
```
44+
45+
# This script assumes the client object is correctly configured
46+
# with your database name, token, and host URL.
47+
# After the script runs, the table variable contains the data
48+
# formatted as a PyArrow table.
49+
```
5350
---
5451

5552
The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python)
@@ -958,7 +955,7 @@ fh.close()
958955
client = InfluxDBClient3(host=f"{{< influxdb/host >}}",
959956
database=f"DATABASE_NAME",
960957
token=f"DATABASE_TOKEN",
961-
fco=flight_client_options(tls_root_certs=cert))
958+
flight_client_options=flight_client_options(tls_root_certs=cert))
962959
```
963960

964961
{{% /code-placeholders %}}

0 commit comments

Comments
 (0)