Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/etl/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def load(df: pd.DataFrame, db_path: str = "etl_data.db", table_name: str = "proc
if db_dir and not os.path.exists(db_dir):
os.makedirs(db_dir)
conn = None
cursor = None
try:
# Connect to database
conn = sqlite3.connect(db_path)
Expand Down Expand Up @@ -59,5 +60,9 @@ def load(df: pd.DataFrame, db_path: str = "etl_data.db", table_name: str = "proc
if conn:
conn.rollback()
finally:
# Ensure cursor is closed
if cursor:
cursor.close()
# Ensure database connection is properly closed
if conn:
conn.close()
Loading