优化pgsql
This commit is contained in:
@@ -2,13 +2,7 @@ import os, sys
|
||||
import logging
|
||||
import pandas as pd
|
||||
import requests
|
||||
from datetime import datetime
|
||||
from goojia_utils import dateutils, oracle
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
os.environ["NLS_LANG"] = "American_America.AL32UTF8"
|
||||
os.environ["ORACLE_HOME"] = "/home/airflow/instantclient_21_7"
|
||||
engine = create_engine("postgresql+psycopg2://postgres:postgres@192.168.0.236:5432/warehouse", echo=False)
|
||||
from goojia_utils import dateutils, pgsql
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
path = "/home/airflow/data/jh/price"
|
||||
@@ -27,8 +21,8 @@ if type == month_last:
|
||||
month_last = month_before
|
||||
log.info(f"测试月份:{month_now}")
|
||||
|
||||
price_df = pd.read_sql(f"select urbn_id,urbn_nm,gujia_admndiv_nm,gujia_bds_id as gujia_comm_id,comm_nm,gujia_bds_clmtd,gujia_comm_basic_prc from t_app_p9pha_plda.avm_community_base_price_gj_h where gujiabds_clc_yrmo_val={month_now} ", con=engine)
|
||||
deal_df = pd.read_sql(f"select gujia_bds_mdl_id,gujia_comm_id,gujia_bds_trdtckt_prc from base.t0831_bigdata_deal_gj_h where to_char(txn_dt,'yyyyMM')='{month_last}' ", con=engine)
|
||||
price_df = pgsql.scan_by_sql_to_data_frame(f"select urbn_id,urbn_nm,gujia_admndiv_nm,gujia_bds_id as gujia_comm_id,comm_nm,gujia_bds_clmtd,gujia_comm_basic_prc from t_app_p9pha_plda.avm_community_base_price_gj_h where gujiabds_clc_yrmo_val={month_now} ")
|
||||
deal_df = pgsql.scan_by_sql_to_data_frame(f"select gujia_bds_mdl_id,gujia_comm_id,gujia_bds_trdtckt_prc from base.t0831_bigdata_deal_gj_h where to_char(txn_dt,'yyyyMM')='{month_last}' ")
|
||||
deal_price_df = deal_df.merge(price_df, on="gujia_comm_id", how="left")
|
||||
deal_price_df["ppe"] = round((deal_price_df["gujia_comm_basic_prc"] - deal_price_df['gujia_bds_trdtckt_prc']) / deal_price_df['gujia_bds_trdtckt_prc'], 4)
|
||||
deal_price_df = deal_price_df[abs(deal_price_df['ppe']) > 0.15]
|
||||
|
||||
Reference in New Issue
Block a user