Refine
This commit is contained in:
@@ -1102,11 +1102,10 @@ def query_latest_record_by_ID(ID: str, type: str, bucket: str="realtime_simulati
|
|||||||
:return: dict: 最新记录的数据,如果没有找到则返回 None。
|
:return: dict: 最新记录的数据,如果没有找到则返回 None。
|
||||||
"""
|
"""
|
||||||
if client.ping():
|
if client.ping():
|
||||||
print("{} -- Successfully connected to InfluxDB.".format(
|
print("{} -- Successfully connected to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
|
||||||
else:
|
else:
|
||||||
print("{} -- Failed to connect to InfluxDB.".format(
|
print("{} -- Failed to connect to InfluxDB.".format(datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
||||||
datetime.now().strftime('%Y-%m-%d %H:%M:%S')))
|
|
||||||
query_api = client.query_api()
|
query_api = client.query_api()
|
||||||
if type == "node":
|
if type == "node":
|
||||||
flux_query = f'''
|
flux_query = f'''
|
||||||
@@ -1188,7 +1187,7 @@ def query_latest_record_by_ID(ID: str, type: str, bucket: str="realtime_simulati
|
|||||||
return {
|
return {
|
||||||
"time": record["_time"],
|
"time": record["_time"],
|
||||||
"device_ID": ID,
|
"device_ID": ID,
|
||||||
"value": record["_value"],
|
"value": record["monitored_value"],
|
||||||
}
|
}
|
||||||
|
|
||||||
return None # 如果没有找到记录
|
return None # 如果没有找到记录
|
||||||
|
|||||||
Reference in New Issue
Block a user