Hello! Are there any dictionaries created through get_org_data, such as dateeal, org_name, cont_a dictionary, rk, stock_name,goal_value,gap_ratio dictionary created through get_for_data Is there a way to put it together?
def get_org_data(self):
sql = f"""
SELECT A.DATEDEAL,
B.ORG_NAME,
A.CONT_A
FROM TP_STOCK.STOCK_CHANGKU_CODE B
INNER JOIN TP_STOCK.ORG_OPINION_MANUAL_MOD A
ON B.ORG_NUM = A.ORG_CODE
INNER JOIN RPT01 C
ON A.DATEDEAL = c.datedeal
join rpt02 d
on c.stk_code = d.stk_code
where (c.stk_code = '{self.stock_code}'
AND c.DATEDEAL BETWEEN 20191223 AND 20191230)
and rownum =1
ORDER BY A.SN DESC
"""
rows = self.data_db_mgr.get_all_rows(sql)
x = []
if not rows:
return x
for r in rows:
x.append(
{
"datedeal": r[0][4:6] + "/" + r[0][6:8],
"org_name": r[1],
"cont_a": r[2],
}
)
return x
def get_for_data(self):
sql = f"""
select rk, stk_name, goal_value, TRUNC(gap_ratio*100)
from rpt02
where period_len =5
AND (DATEDEAL = '{self.deal_date}'
and rownum <= 5)
order by rk asc
"""
rows = self.data_db_mgr.get_all_rows(sql)
x = []
if not rows:
return x
for r in rows:
x.append(
{
"rk": r[0],
"stock_name": r[1],
"goal_value": r[2],
"gap_ratio": r[3],
}
)
return x
You can add dictionary elements with the update command.
a = get_org_data()[0]
b = get_for_data()[0]
a.update(b)
print(a)
© 2024 OneMinuteCode. All rights reserved.