Enable gzip for influxdb client

This commit is contained in:
DingZQ
2025-04-13 17:40:58 +08:00
parent a8db5d63a2
commit e4aa0f20b8

View File

@@ -171,7 +171,11 @@ def query_pg_scada_info_non_realtime(name: str) -> None:
# 2025/03/23
def get_new_client() -> InfluxDBClient:
"""每次调用返回一个新的 InfluxDBClient 实例。"""
return InfluxDBClient(url=url, token=token, org=org_name, timeout=600*1000) # 600 seconds
return InfluxDBClient(url=url,
token=token,
org=org_name,
enable_gzip=True,
timeout=600*1000) # 600 seconds
# 2025/04/11, DingZQ
def create_write_options() -> WriteOptions:
@@ -3115,11 +3119,11 @@ if __name__ == "__main__":
client = InfluxDBClient(url=url, token=token)
# step1: 检查连接状态初始化influxdb的buckets
# try:
# # delete_buckets(org_name)
# create_and_initialize_buckets(org_name)
# except Exception as e:
# print(f"连接失败: {e}")
try:
# delete_buckets(org_name)
create_and_initialize_buckets(org_name)
except Exception as e:
print(f"连接失败: {e}")
# step2: 先查询pg数据库中scada_info的信息然后存储SCADA数据到SCADA_data这个bucket里