Add missing secrets import
This commit is contained in:
parent
d024f3b0d5
commit
c4da02fc6e
19
app/main.py
19
app/main.py
@ -4,6 +4,7 @@ import io
|
|||||||
import gzip
|
import gzip
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
|
import secrets
|
||||||
from typing import List, Dict, Set
|
from typing import List, Dict, Set
|
||||||
|
|
||||||
# Third-party library imports
|
# Third-party library imports
|
||||||
@ -784,17 +785,21 @@ async def stock_balance_sheet(data: TickerData):
|
|||||||
symbol = ?
|
symbol = ?
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
df = pd.read_sql_query(query_template,con, params=(ticker,))
|
with db_connection(STOCK_DB) as cursor:
|
||||||
balance_statement = ujson.loads(df['balance'].iloc[0])
|
cursor.execute(query_template, (ticker,))
|
||||||
balance_statement_growth = ujson.loads(df['balance_growth'].iloc[0])
|
result = cursor.fetchone()
|
||||||
|
if result:
|
||||||
res = clean_financial_data(balance_statement,balance_statement_growth)
|
balance_statement = ujson.loads(result[0])
|
||||||
|
balance_statement_growth = ujson.loads(result[1])
|
||||||
|
res = clean_financial_data(balance_statement, balance_statement_growth)
|
||||||
|
else:
|
||||||
|
res = []
|
||||||
except:
|
except:
|
||||||
res = []
|
res = []
|
||||||
|
|
||||||
redis_client.set(cache_key, ujson.dumps(res))
|
redis_client.set(cache_key, ujson.dumps(res))
|
||||||
redis_client.expire(cache_key, 3600*3600) # Set cache expiration time to 1 hour
|
redis_client.expire(cache_key, 3600*3600)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@app.post("/stock-ratios")
|
@app.post("/stock-ratios")
|
||||||
async def stock_ratios(data: TickerData):
|
async def stock_ratios(data: TickerData):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user