From deab1ec0bb9751eac343b953b29a31e97d47ff1c Mon Sep 17 00:00:00 2001 From: jingboyitiji Date: Wed, 26 Mar 2025 13:32:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=B3=E6=B2=B9=E7=84=A6=E7=99=BE=E5=B7=9D?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2sql=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_shiyoujiao_lvyong.py | 2 +- lib/dataread.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/config_shiyoujiao_lvyong.py b/config_shiyoujiao_lvyong.py index 20dfdad..bb3b82d 100644 --- a/config_shiyoujiao_lvyong.py +++ b/config_shiyoujiao_lvyong.py @@ -304,7 +304,7 @@ table_name = 'v_tbl_crude_oil_warning' baichuan_table_name = 'V_TBL_BAICHUAN_YINGFU_VALUE' # select BAICHUAN_ID, DATA_DATE, DATA_VALUE from V_TBL_BAICHUAN_YINGFU_VALUE where BAICHUAN_ID in ('1588348470396475286', '1666') # 开关 -is_train = False # 是否训练 +is_train = True # 是否训练 is_debug = False # 是否调试 is_eta = True # 是否使用eta接口 is_market = False # 是否通过市场信息平台获取特征 ,在is_eta 为true 的情况下生效 diff --git a/lib/dataread.py b/lib/dataread.py index 00753bf..73463a7 100644 --- a/lib/dataread.py +++ b/lib/dataread.py @@ -2224,13 +2224,14 @@ def addtimecharacteristics(df, dataset): def get_baichuan_data(baichuanidnamedict): baichuanidlist = [str(k) for k in baichuanidnamedict.keys()] baichuanidlist= [f"'{id}'" for id in baichuanidlist] + startdate = str(config.start_year)+'0101' # 连接数据库 db = config.db_mysql if db is None: db.connect() # 执行SQL查询 select BAICHUAN_ID,DATA_DATE,DATA_VALUE from V_TBL_BAICHUAN_YINGFU_VALUE where BAICHUAN_ID in ('1588348470396475286','1666'); - sql = f"SELECT BAICHUAN_ID,DATA_DATE,DATA_VALUE FROM {global_config['baichuan_table_name']} WHERE BAICHUAN_ID in ({','.join(baichuanidlist)})" - + sql = f"SELECT BAICHUAN_ID,DATA_DATE,DATA_VALUE FROM {global_config['baichuan_table_name']} WHERE DATA_DATE >= {startdate} AND BAICHUAN_ID in ({','.join(baichuanidlist)})" + print(sql) # 获取查询结果 results = db.execute_query(sql) df = pd.DataFrame(results, columns=[