Loading backend/db.py +13 −2 Original line number Diff line number Diff line Loading @@ -37,14 +37,24 @@ def init_db(): """) conn.commit() def store_nvda_data(): df = yf.Ticker("NVDA").history(period="5y") df = df[["Open", "High", "Low", "Close", "Volume"]] df.reset_index(inplace=True) df.columns = ["date", "open", "high", "low", "close", "volume"] # Convert to native Python types to avoid psycopg2 type errors df = df.astype({ "open": float, "high": float, "low": float, "close": float, "volume": int }) records = df.to_records(index=False) values = [tuple(r) for r in records] values = [tuple(map(lambda x: x.item() if hasattr(x, "item") else x, row)) for row in records] insert_query = """ INSERT INTO nvda_stock (date, open, high, low, close, volume) Loading @@ -57,6 +67,7 @@ def store_nvda_data(): execute_values(cur, insert_query, values) conn.commit() def get_nvda_data(): with get_connection() as conn: with conn.cursor() as cur: Loading frontend/public/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>GDP Viewer</title> <title>YF App</title> </head> <body> <div id="root"></div> Loading Loading
backend/db.py +13 −2 Original line number Diff line number Diff line Loading @@ -37,14 +37,24 @@ def init_db(): """) conn.commit() def store_nvda_data(): df = yf.Ticker("NVDA").history(period="5y") df = df[["Open", "High", "Low", "Close", "Volume"]] df.reset_index(inplace=True) df.columns = ["date", "open", "high", "low", "close", "volume"] # Convert to native Python types to avoid psycopg2 type errors df = df.astype({ "open": float, "high": float, "low": float, "close": float, "volume": int }) records = df.to_records(index=False) values = [tuple(r) for r in records] values = [tuple(map(lambda x: x.item() if hasattr(x, "item") else x, row)) for row in records] insert_query = """ INSERT INTO nvda_stock (date, open, high, low, close, volume) Loading @@ -57,6 +67,7 @@ def store_nvda_data(): execute_values(cur, insert_query, values) conn.commit() def get_nvda_data(): with get_connection() as conn: with conn.cursor() as cur: Loading
frontend/public/index.html +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>GDP Viewer</title> <title>YF App</title> </head> <body> <div id="root"></div> Loading