diff --git a/content/influxdb/v2.4/api-guide/client-libraries/python.md b/content/influxdb/v2.4/api-guide/client-libraries/python.md index 52b5cb994..16026cd22 100644 --- a/content/influxdb/v2.4/api-guide/client-libraries/python.md +++ b/content/influxdb/v2.4/api-guide/client-libraries/python.md @@ -97,6 +97,7 @@ client = influxdb_client.InfluxDBClient( org=org ) +# Write script write_api = client.write_api(write_options=SYNCHRONOUS) p = influxdb_client.Point("my_measurement").tag("location", "Prague").field("temperature", 25.3) @@ -157,12 +158,28 @@ write_api.write(bucket=bucket, org=org, record=p) ### Complete example query script ```python +import influxdb_client +from influxdb_client.client.write_api import SYNCHRONOUS + +bucket = "" +org = "" +token = "" +# Store the URL of your InfluxDB instance +url="http://localhost:8086" + +client = influxdb_client.InfluxDBClient( + url=url, + token=token, + org=org +) + +# Query script query_api = client.query_api() -query = ‘ from(bucket:"my-bucket")\ +query = 'from(bucket:"my-bucket")\ |> range(start: -10m)\ |> filter(fn:(r) => r._measurement == "my_measurement")\ |> filter(fn: (r) => r.location == "Prague")\ -|> filter(fn:(r) => r._field == "temperature" )‘ +|> filter(fn:(r) => r._field == "temperature" )' result = query_api.query(org=org, query=query) results = [] for table in result: