@@ -228,12 +228,12 @@ def commit_batch(self):
228228 self .batch_buffer = []
229229 self .last_commit_time = time .time ()
230230
231- # Return the count of committed records
232- return count
233-
234231 except sqlite3 .Error as e :
235- self .logger .error (f"Failed to commit batch: { e } " )
232+ self .logger .exception (f"Failed to commit batch: { e } " )
236233 raise
234+ else :
235+ # Return the count of committed records
236+ return count
237237 # Ignore read-only errors on close
238238
239239 # Checkpoint WAL to ensure data is written to main database file
@@ -350,9 +350,10 @@ def is_healthy(self) -> bool:
350350 cursor = self .conn .cursor ()
351351 cursor .execute ("SELECT 1" )
352352 cursor .fetchone ()
353- return True
354353 except Exception :
355354 return False
355+ else :
356+ return True
356357
357358 def get_readings (self , limit : int | None = None ) -> list :
358359 """Get sensor readings from the database."""
@@ -367,7 +368,7 @@ def get_readings(self, limit: int | None = None) -> list:
367368 rows = cursor .fetchall ()
368369 return [dict (zip (columns , row , strict = False )) for row in rows ]
369370 except Exception as e :
370- self .logger .error (f"Failed to get readings: { e } " )
371+ self .logger .exception (f"Failed to get readings: { e } " )
371372 return []
372373
373374 def get_reading_stats (self ) -> dict :
@@ -422,7 +423,7 @@ def get_database_stats(self) -> dict:
422423 },
423424 }
424425 except Exception as e :
425- self .logger .error (f"Failed to get database stats: { e } " )
426+ self .logger .exception (f"Failed to get database stats: { e } " )
426427 return {
427428 "total_readings" : 0 ,
428429 "anomaly_count" : 0 ,
0 commit comments