估值监测和波动变化修改查pg库

This commit is contained in:
xuhe
2023-02-20 14:35:22 +08:00
parent ea31154106
commit 99dd02dd05
2 changed files with 23 additions and 12 deletions
+10 -7
View File
@@ -7,9 +7,10 @@ import logging
import os
import sys
import requests
from sqlalchemy import create_engine
os.environ["ORACLE_HOME"] = "/home/airflow/instantclient_21_7"
engine = create_engine("postgresql+psycopg2://postgres:postgres@192.168.0.236:5432/postgres", echo=False)
def simple_calc(result_df):
"""
新增是否有样本列
@@ -25,8 +26,9 @@ def simple_calc(result_df):
if len(actions) == 800:
ins = "','".join(actions)
ins = "'" + ins + "'"
simple_temp_df = oracle.scan_by_sql_to_data_frame("select distinct commid from bigdata_forsale_gj where " +
" publishtime> TO_DATE('" + month_before + "','YYYY-MM-DD') and commid in (" + ins + ")")
simple_temp_df = pd.read_sql(
"select distinct gujia_comm_id as commid from base.t0831_bigdata_forsale_gj_h where " +
" anc_tm> TO_DATE('" + month_before + "','YYYY-MM-DD') and gujia_comm_id in (" + ins + ")", con=engine)
simple_df = pd.concat([simple_df, simple_temp_df])
actions.clear()
@@ -34,8 +36,9 @@ def simple_calc(result_df):
if len(actions) > 0:
ins = "','".join(actions)
ins = "'" + ins + "'"
simple_temp_df = oracle.scan_by_sql_to_data_frame("select distinct commid from bigdata_forsale_gj where " +
" publishtime> TO_DATE('" + month_before + "','YYYY-MM-DD') and commid in (" + ins + ")")
simple_temp_df = pd.read_sql(
"select distinct gujia_comm_id as commid from base.t0831_bigdata_forsale_gj_h where " +
" anc_tm> TO_DATE('" + month_before + "','YYYY-MM-DD') and gujia_comm_id in (" + ins + ")", con=engine)
simple_df = pd.concat([simple_df, simple_temp_df])
actions.clear()
simple_df['has_sample'] = 1
@@ -85,8 +88,8 @@ if type == month_last:
month_now = month_last
month_last = month_before
df = oracle.scan_by_sql_to_data_frame("SELECT id, cityname, distname, commid, commname, calc_type, confidence, avg_price, year_month FROM community_base_price_gj WHERE year_month IN('"+month_now+"', '"+month_last+"') " +
" ORDER BY cityname, distname, commid, commname, year_month")
df = pd.read_sql("SELECT gujia_bss_prc_id as id, urbn_nm as cityname, gujia_admndiv_nm as distname, gujia_bds_id as commid, comm_nm as commname, gujia_bds_clmtd as calc_type, gujia_bds_cfdc_dgr as confidence, gujia_comm_basic_prc as avg_price, gujiabds_clc_yrmo_val as year_month FROM t_app_p9pha_plda.avm_community_base_price_gj_h WHERE gujiabds_clc_yrmo_val IN('"+month_now+"', '"+month_last+"') " +
" ORDER BY urbn_nm, gujia_admndiv_nm, gujia_bds_id, comm_nm, gujia_bds_clmtd", con=engine)
six_map = dict()
five_map = dict()