替换 localhost 为 127.0.0.1,避免 DNS 解析影响响应速度

This commit is contained in:
JIANG
2025-12-02 10:48:53 +08:00
parent 33c467fe39
commit 523fee275f
7 changed files with 12 additions and 25 deletions

3
.gitignore vendored
View File

@@ -1,4 +1,5 @@
*.pyc
.env
db_inp/
temp/
temp/
data/

View File

@@ -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

View File

@@ -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()

View File

@@ -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" # 要删除的起始时间

View File

@@ -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名称

View File

@@ -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

View File

@@ -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)