From 523fee275ff51cbdc4b3397686e807d53f369c5e Mon Sep 17 00:00:00 2001 From: JIANG Date: Tue, 2 Dec 2025 10:48:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BF=E6=8D=A2=20localhost=20=E4=B8=BA=2012?= =?UTF-8?q?7.0.0.1=EF=BC=8C=E9=81=BF=E5=85=8D=20DNS=20=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=E5=93=8D=E5=BA=94=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- InfluxDb Information.txt | 14 -------------- auto_cache.py | 6 +++--- influxdb_api.py | 5 +++-- influxdb_info.py | 5 ++--- main.py | 2 +- redis_clear_all_keys.py | 2 +- 7 files changed, 12 insertions(+), 25 deletions(-) delete mode 100644 InfluxDb Information.txt diff --git a/.gitignore b/.gitignore index 0edd5bd..79805df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.pyc .env db_inp/ -temp/ \ No newline at end of file +temp/ +data/ diff --git a/InfluxDb Information.txt b/InfluxDb Information.txt deleted file mode 100644 index 9bcfa4c..0000000 --- a/InfluxDb Information.txt +++ /dev/null @@ -1,14 +0,0 @@ -UserName tjwater -Password Tjwater@123456 -Organizatio TJWATEORG -Bucket TJWATERBUCKET - -API Token : xGDM5RZqRJAuzAGS-otXUdC2NFdY75qJAjRLqAB4p5WcIIAlIUpOpT8_yA16AOHmJWerwQ_08gwb84sy42jnZQ== - - - -influx config create --config-name onboarding ` - --host-url "http://localhost:8086" ` - --org "TJWATERORG" ` - --token "p4Hq6DQ4xI6yA2tZQgo-VGzjWObylyWd4B45vMoiae0XJeNUlL87FdEUU5cJ63O87W7-nAhhGWl_0FGJiL801w==" ` - --active diff --git a/auto_cache.py b/auto_cache.py index 3c7dfb1..451c584 100644 --- a/auto_cache.py +++ b/auto_cache.py @@ -46,7 +46,7 @@ def queryallrecordsbydate_by_url(querydate: str): try: response = urllib.request.urlopen( - f"http://localhost/queryallrecordsbydate/?querydate={querydate}" + f"http://127.0.0.1/queryallrecordsbydate/?querydate={querydate}" ) html = response.read().decode("utf-8") @@ -66,7 +66,7 @@ def queryallscadarecordsbydate_by_url(querydate: str): try: response = urllib.request.urlopen( - f"http://localhost/queryallscadarecordsbydate/?querydate={querydate}" + f"http://127.0.0.1/queryallscadarecordsbydate/?querydate={querydate}" ) html = response.read().decode("utf-8") @@ -77,7 +77,7 @@ def queryallscadarecordsbydate_by_url(querydate: str): def auto_cache_data(): # 初始化 Redis 连接 # 用redis 限制并发访u - redis_client = redis.Redis(host="localhost", port=6379, db=0) + redis_client = redis.Redis(host="127.0.0.1", port=6379, db=0) # auto cache data for the last 3 days today = datetime.date.today() diff --git a/influxdb_api.py b/influxdb_api.py index bc4c877..b9afd39 100644 --- a/influxdb_api.py +++ b/influxdb_api.py @@ -4930,7 +4930,8 @@ if __name__ == "__main__": # print(leakage) # 示例:upload_cleaned_SCADA_data_to_influxdb - upload_cleaned_SCADA_data_to_influxdb(file_path="./标准cleaned_demand_data.csv") + import_multicolumn_data_from_file(file_path='data/szh_pressure_scada.csv', raw=True, bucket='SCADA_data') + import_multicolumn_data_from_file(file_path='data/szh_flow_scada_converted.csv', raw=True, bucket='SCADA_data') # 示例:delete_data # delete_data(delete_date='2025-05-04', bucket='SCADA_data') @@ -4952,7 +4953,7 @@ if __name__ == "__main__": # 示例:import_multicolumn_data_from_file # import_multicolumn_data_from_file(file_path='data/selected_Flow_Timedata2025_new_format_cleaned.csv', raw=False, bucket='SCADA_data') - # client = InfluxDBClient(url="http://localhost:8086", token=token, org=org_name) + # client = InfluxDBClient(url="http://127.0.0.1:8086", token=token, org=org_name) # delete_api = client.delete_api() # start = "2025-08-02T00:00:00Z" # 要删除的起始时间 diff --git a/influxdb_info.py b/influxdb_info.py index 25dcedf..8ea0439 100644 --- a/influxdb_info.py +++ b/influxdb_info.py @@ -1,7 +1,6 @@ - # influxdb数据库连接信息 -url = "http://localhost:8086" # 替换为你的InfluxDB实例地址 +url = "http://127.0.0.1:8086" # 替换为你的InfluxDB实例地址 token = "kMPX2V5HsbzPpUT2B9HPBu1sTG1Emf-lPlT2UjxYnGAuocpXq_f_0lK4HHs-TbbKyjsZpICkMsyXG_V2D7P7yQ==" # 替换为你的InfluxDB Token -# _ENCODED_TOKEN = "eEdETTVSWnFSSkF1ekFHUy1vdFhVZEMyTkZkWTc1cUpBalJMcUFCNHA1V2NJSUFsSVVwT3BUOF95QTE2QU9IbUpXZXJ3UV8wOGd3Yjg0c3k0MmpuWlE9PQ==" +# _ENCODED_TOKEN = "eEdETTVSWnFSSkF1ekFHUy1vdFhVZEMyTkZkWTc1cUpBalJMcUFCNHA1V2NJSUFsSVVwT3BUOF95QTE2QU9IbUpXZXJ3UV8wOGd3Yjg0c3k0MmpuWlE9PQ==" # token = base64.b64decode(_ENCODED_TOKEN).decode("utf-8") org = "TJWATERORG" # 替换为你的Organization名称 diff --git a/main.py b/main.py index 36e8185..f576146 100644 --- a/main.py +++ b/main.py @@ -157,7 +157,7 @@ def decode_datetime(obj): # 初始化 Redis 连接 # 用redis 限制并发访u -redis_client = redis.Redis(host="localhost", port=6379, db=0) +redis_client = redis.Redis(host="127.0.0.1", port=6379, db=0) # influxdb数据库连接信息 # influx_url = influxdb_info.url diff --git a/redis_clear_all_keys.py b/redis_clear_all_keys.py index 3e76970..136e14e 100644 --- a/redis_clear_all_keys.py +++ b/redis_clear_all_keys.py @@ -1,5 +1,5 @@ import redis -redis_client = redis.Redis(host="localhost", port=6379, db=0) +redis_client = redis.Redis(host="127.0.0.1", port=6379, db=0) matched_keys = redis_client.keys(f"**") redis_client.delete(*matched_keys)