harbor run -t openthoughts/tasktrove-exp-rpt-curriculum-easy-curriculum-easy-0031harbor download openthoughts/tasktrove-exp-rpt-curriculum-easy-curriculum-easy-0031Goal
What to implement (keep it minimal)
Notes and guidance
Skeleton (to help you get started) You may start from a minimal skeleton like this in /app/db_utils.py and fill in the implementation:
# /app/db_utils.py
"""
Lightweight SQLite-backed utilities for pandas DataFrames.
Two simple functions:
- write_db_table: write a DataFrame to SQLite with controlled if_exists behavior.
- read_sql_table: read a table from SQLite into a DataFrame.
"""
import sqlite3
from typing import Optional
import pandas as pd
def write_db_table(table_name: str, df: pd.DataFrame, if_exists: str, sqlite_path: str) -> None:
"""
Write a DataFrame to a SQLite table.
Parameters:
- table_name: name of the destination table in SQLite.
- df: DataFrame to write.
- if_exists: policy for existing table ('replace' or 'append').
- sqlite_path: path to the SQLite database file.
Behavior:
- Creates the database file if it does not exist.
- Writes the DataFrame with index=False.
- Raises ValueError for unsupported if_exists values.
- Closes the connection after writing.
"""
# TODO: implement
def read_sql_table(table_name: str, sqlite_path: str) -> pd.DataFrame:
"""
Read an entire SQLite table into a DataFrame.
Parameters:
- table_name: name of the table to read.
- sqlite_path: path to the SQLite database file.
Returns:
- A pandas DataFrame containing the table data.
"""
# TODO: implement
Hints