Skip to content

Commit acdd065

Browse files
committed
feat: ensure database connection and cursor are properly closed
1 parent aa97624 commit acdd065

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

app/etl/load.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def load(df: pd.DataFrame, db_path: str = "etl_data.db", table_name: str = "proc
2323
if db_dir and not os.path.exists(db_dir):
2424
os.makedirs(db_dir)
2525
conn = None
26+
cursor = None
2627
try:
2728
# Connect to database
2829
conn = sqlite3.connect(db_path)
@@ -59,5 +60,9 @@ def load(df: pd.DataFrame, db_path: str = "etl_data.db", table_name: str = "proc
5960
if conn:
6061
conn.rollback()
6162
finally:
63+
# Ensure cursor is closed
64+
if cursor:
65+
cursor.close()
66+
# Ensure database connection is properly closed
6267
if conn:
6368
conn.close()

0 commit comments

Comments
 (0)