Spaces:
Sleeping
Sleeping
Update database/db.py
Browse files- database/db.py +16 -1
database/db.py
CHANGED
|
@@ -395,4 +395,19 @@ def read_batter_prop_outcomes(conn) -> pd.DataFrame:
|
|
| 395 |
FROM batter_prop_outcomes
|
| 396 |
ORDER BY graded_at DESC, created_at DESC
|
| 397 |
"""
|
| 398 |
-
).df()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 395 |
FROM batter_prop_outcomes
|
| 396 |
ORDER BY graded_at DESC, created_at DESC
|
| 397 |
"""
|
| 398 |
+
).df()
|
| 399 |
+
|
| 400 |
+
def replace_batter_prop_outcomes(conn, df: pd.DataFrame) -> None:
|
| 401 |
+
if df is None or df.empty:
|
| 402 |
+
return
|
| 403 |
+
|
| 404 |
+
ensure_batter_prop_outcomes_table(conn)
|
| 405 |
+
conn.execute("DELETE FROM batter_prop_outcomes")
|
| 406 |
+
conn.register("batter_prop_outcomes_replace_df", df)
|
| 407 |
+
conn.execute(
|
| 408 |
+
"""
|
| 409 |
+
INSERT INTO batter_prop_outcomes
|
| 410 |
+
SELECT * FROM batter_prop_outcomes_replace_df
|
| 411 |
+
"""
|
| 412 |
+
)
|
| 413 |
+
conn.unregister("batter_prop_outcomes_replace_df")
|