From 13cdae636213a6c1ec3788c69558796d212d78f2 Mon Sep 17 00:00:00 2001 From: DingZQ Date: Sat, 15 Feb 2025 15:02:00 +0800 Subject: [PATCH] Refine --- influxdb_api.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/influxdb_api.py b/influxdb_api.py index 7f15d4a..d1504a1 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -1102,11 +1102,10 @@ def query_latest_record_by_ID(ID: str, type: str, bucket: str="realtime_simulati :return: dict: 最新记录的数据,如果没有找到则返回 None。 """ if client.ping(): - print("{} -- Successfully connected to InfluxDB.".format( - datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + print("{} -- Successfully connected to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) else: - print("{} -- Failed to connect to InfluxDB.".format( - datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + print("{} -- Failed to connect to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S'))) + query_api = client.query_api() if type == "node": flux_query = f''' @@ -1188,7 +1187,7 @@ def query_latest_record_by_ID(ID: str, type: str, bucket: str="realtime_simulati return { "time": record["_time"], "device_ID": ID, - "value": record["_value"], + "value": record["monitored_value"], } return None # 如果没有找到记录