diff --git a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md index 9c7afbbfe..d8e3e5ad6 100644 --- a/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-dedicated/reference/client-libraries/v3/python.md @@ -8,38 +8,45 @@ menu: parent: v3 client libraries identifier: influxdb3-python influxdb/cloud-dedicated/tags: [Flight API, python, gRPC, SQL, client libraries] -metadata: [influxdb3-python v0.5.0] +metadata: [influxdb3-python v0.10.0] weight: 201 aliases: - /influxdb/cloud-dedicated/reference/client-libraries/v3/pyinflux3/ related: - /influxdb/cloud-dedicated/query-data/execute-queries/troubleshoot/ -list_code_example: > - +list_code_example: | + + + + ```python # Example: Write and query data - - # Write sensor data into influxDB - - # and retrieve data from the last 90 days for analysis. - - # Write sensor data in batches from a CSV file - client.write_file(file='./data/home-sensor-data.csv', timestamp_column='time', - tag_columns=["room"]) + # Write sensor data in batches from a CSV file to a database + client.write_file(file='./data/home-sensor-data.csv', + timestamp_column='time', + tag_columns=["room"]) - # Execute a query and retrieve data formatted as a PyArrow Table - table = client.query( + # Execute a query and retrieve data from the last 90 days + table = client.query( '''SELECT * FROM home WHERE time >= now() - INTERVAL '90 days' ORDER BY time''') - - # This script assumes the client object is correctly configured with your database name, token, and host URL. - # After the script runs, the table variable contains the data formatted as a PyArrow table. - ``` - + # This script assumes the client object is correctly configured + # with your database name, token, and host URL. + # After the script runs, the table variable contains the data + # formatted as a PyArrow table. + ``` --- The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python) @@ -947,7 +954,7 @@ fh.close() client = InfluxDBClient3(host=f"{{< influxdb/host >}}", database=f"DATABASE_NAME", token=f"DATABASE_TOKEN", - fco=flight_client_options(tls_root_certs=cert)) + flight_client_options=flight_client_options(tls_root_certs=cert)) ``` {{% /code-placeholders %}} diff --git a/content/influxdb/cloud-serverless/reference/client-libraries/v3/python.md b/content/influxdb/cloud-serverless/reference/client-libraries/v3/python.md index 492e8d1d9..28695d39e 100644 --- a/content/influxdb/cloud-serverless/reference/client-libraries/v3/python.md +++ b/content/influxdb/cloud-serverless/reference/client-libraries/v3/python.md @@ -9,12 +9,45 @@ menu: identifier: influxdb3-python influxdb/cloud-serverless/tags: [Flight API, python, gRPC, SQL, client libraries] -metadata: [influxdb3-python v0.5.0] +metadata: [influxdb3-python v0.10.0] weight: 201 aliases: - /influxdb/cloud-serverless/reference/client-libraries/v3/pyinflux3/ related: - /influxdb/cloud-serverless/query-data/execute-queries/troubleshoot/ +list_code_example: | + + + + + ```python + # Example: Write and query data + + # Write sensor data in batches from a CSV file to a database + client.write_file(file='./data/home-sensor-data.csv', + timestamp_column='time', + tag_columns=["room"]) + + # Execute a query and retrieve data from the last 90 days + table = client.query( + '''SELECT * + FROM home + WHERE time >= now() - INTERVAL '90 days' + ORDER BY time''') + + # This script assumes the client object is correctly configured + # with your bucket name, token, and host URL. + # After the script runs, the table variable contains the data + # formatted as a PyArrow table. + ``` --- The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python/) @@ -939,7 +972,7 @@ fh.close() client = InfluxDBClient3(host=f"{{< influxdb/host >}}", database=f"BUCKET_NAME", token=f"API_TOKEN", - fco=flight_client_options(tls_root_certs=cert)) + flight_client_options=flight_client_options(tls_root_certs=cert)) ``` {{% /code-placeholders %}} diff --git a/content/influxdb/clustered/reference/client-libraries/v3/python.md b/content/influxdb/clustered/reference/client-libraries/v3/python.md index b9070c1fe..7c5b12a58 100644 --- a/content/influxdb/clustered/reference/client-libraries/v3/python.md +++ b/content/influxdb/clustered/reference/client-libraries/v3/python.md @@ -8,48 +8,45 @@ menu: parent: v3 client libraries identifier: influxdb3-python influxdb/clustered/tags: [Flight API, python, gRPC, SQL, client libraries] -metadata: [influxdb3-python v0.5.0] +metadata: [influxdb3-python v0.10.0] weight: 201 aliases: - /influxdb/clustered/reference/client-libraries/v3/pyinflux3/ related: - /influxdb/clustered/query-data/execute-queries/troubleshoot/ list_code_example: | - + ```python - from influxdb_client_3 import(InfluxDBClient3, - WriteOptions, - write_client_options) + # Example: Write and query data - # Instantiate batch writing options for the client + # Write sensor data in batches from a CSV file to a database + client.write_file(file='./data/home-sensor-data.csv', + timestamp_column='time', + tag_columns=["room"]) - write_options = WriteOptions() - wco = write_client_options(write_options=write_options) - - # Instantiate an InfluxDB v3 client - - with InfluxDBClient3(host=f"{{< influxdb/host >}}", - database=f"DATABASE_NAME", - token=f"DATABASE_TOKEN", - write_client_options=wco) as client: - - # Write data in batches - client.write_file(file='./data/home-sensor-data.csv', timestamp_column='time', - tag_columns=["room"]) - - # Execute a query and retrieve data formatted as a PyArrow Table - - table = client.query( + # Execute a query and retrieve data from the last 90 days + table = client.query( '''SELECT * FROM home WHERE time >= now() - INTERVAL '90 days' ORDER BY time''') - ``` + + # This script assumes the client object is correctly configured + # with your database name, token, and host URL. + # After the script runs, the table variable contains the data + # formatted as a PyArrow table. + ``` --- The InfluxDB v3 [`influxdb3-python` Python client library](https://github.com/InfluxCommunity/influxdb3-python) @@ -958,7 +955,7 @@ fh.close() client = InfluxDBClient3(host=f"{{< influxdb/host >}}", database=f"DATABASE_NAME", token=f"DATABASE_TOKEN", - fco=flight_client_options(tls_root_certs=cert)) + flight_client_options=flight_client_options(tls_root_certs=cert)) ``` {{% /code-placeholders %}}