🐛 Problem
The codebase has inconsistent database connection handling. Many functions open SQLite connections without using Python's context manager (with statement), which can lead to:
- Connection leaks - If an exception occurs before
conn.close(), the connection stays open
- Resource exhaustion - Too many open connections can exhaust system resources
- Data corruption risk - Uncommitted transactions may be left in inconsistent states
📍 Current Problematic Pattern
# ❌ Current pattern found in multiple files
conn = sqlite3.connect("users.db")
cursor = conn.cursor()
cursor.execute("SELECT ...")
result = cursor.fetchone()
conn.close() # ⚠️ May not be reached if exception occurs above!