Skip to content

Commit 7b3d740

Browse files
Merge pull request #24 from Satvik-Singh192/feat/add-load-error-handling-8
fix(load): Add try/except/finally error handling to load function
2 parents 5e52171 + 0a6d09d commit 7b3d740

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

app/etl/load.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ def load(df: pd.DataFrame, db_path: str = "etl_data.db", table_name: str = "proc
3535
# TODO (Find & Fix): Idempotency check missing (should avoid duplicate inserts)
3636
# TODO (Find & Fix): Bulk insert without checking for duplicates
3737
df.to_sql(table_name, conn, if_exists="append", index=False)
38+
conn.commit()
3839

3940
except sqlite3.Error as e:
40-
# TODO (Find & Fix): Error handling missing
41-
pass
41+
if conn:
42+
conn.rollback()
4243
except Exception as e:
43-
# TODO (Find & Fix): Error handling missing
44-
pass
44+
if conn:
45+
conn.rollback()
4546
finally:
46-
# TODO (Find & Fix): Connection not closed properly
47-
pass
47+
if conn:
48+
conn.close()

0 commit comments

Comments
 (0)