Syntrex commited on
Commit
b351835
·
verified ·
1 Parent(s): 11a48b1

Update database/db.py

Browse files
Files changed (1) hide show
  1. database/db.py +43 -1
database/db.py CHANGED
@@ -343,4 +343,46 @@ def read_game_outcomes(conn) -> pd.DataFrame:
343
  FROM game_outcomes
344
  ORDER BY graded_at DESC
345
  """
346
- ).df()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
343
  FROM game_outcomes
344
  ORDER BY graded_at DESC
345
  """
346
+ ).df()
347
+
348
+ def ensure_batter_prop_outcomes_table(conn) -> None:
349
+ conn.execute(
350
+ """
351
+ CREATE TABLE IF NOT EXISTS batter_prop_outcomes (
352
+ created_at TEXT,
353
+ graded_at TEXT,
354
+ game_pk TEXT,
355
+ away_team TEXT,
356
+ home_team TEXT,
357
+ slot TEXT,
358
+ batter_name TEXT,
359
+ pitcher_name TEXT,
360
+ market TEXT,
361
+ fair_hr_odds DOUBLE,
362
+ book_hr_odds DOUBLE,
363
+ adjusted_edge DOUBLE,
364
+ confidence DOUBLE,
365
+ recommendation_tier TEXT,
366
+ realized_hit INTEGER,
367
+ realized_hr INTEGER,
368
+ realized_tb2p INTEGER,
369
+ grade_status TEXT,
370
+ outcome_source TEXT
371
+ )
372
+ """
373
+ )
374
+
375
+
376
+ def insert_batter_prop_outcomes(conn, df: pd.DataFrame) -> None:
377
+ if df is None or df.empty:
378
+ return
379
+
380
+ ensure_batter_prop_outcomes_table(conn)
381
+ conn.register("batter_prop_outcomes_df", df)
382
+ conn.execute(
383
+ """
384
+ INSERT INTO batter_prop_outcomes
385
+ SELECT * FROM batter_prop_outcomes_df
386
+ """
387
+ )
388
+ conn.unregister("batter_prop_outcomes_df")