Closed rwader-swi closed 3 months ago
Hi @rwader-swi,
Thank you for using our client. Based on your description, it seems there might be an issue with the query you are using or the data you are querying. To help you achieve the correct response, I've prepared a working example specifically tailored to your data scenario:
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
with InfluxDBClient(url="http://localhost:8086", token="my-token", org="my-org", debug=False) as client:
# Creating test points
test1 = Point("pullrequest").tag("key1", "value1").field("status", "value2")
test2 = Point("pullrequest").tag("key3", "value3").field("status", "value4")
# Writing points to the database
write_api = client.write_api(write_options=SYNCHRONOUS)
write_api.write(bucket="my-bucket", record=[test1, test2])
# Querying written data and printing the results
query_api = client.query_api()
tables = query_api.query('from(bucket:"my-bucket") |> range(start: -10m) |> filter(fn: (r) => r._measurement == "pullrequest")')
for table in tables:
for record in table.records:
print(record.values)
This example demonstrates how to correctly structure data points using Point
objects, write them to InfluxDB, and retrieve them with a query that filters based on the measurement name. Please make sure your bucket name, token, and organization details are correctly set up as per your environment.
Try running this example in your setup, and see if it resolves the issues you are experiencing. If you continue to face problems or have any other questions, feel free to reach out.
Best Regards.
Specifications
Code sample to reproduce problem
Expected behavior
Actual behavior
Instead of "value2" string I get 0, and instead of "value4" string I get 1, and so on.
Additional info
No response