ariankhalfani commited on
Commit
cac84ce
1 Parent(s): dc24feb

Update database.py

Browse files
Files changed (1) hide show
  1. database.py +12 -0
database.py CHANGED
@@ -78,6 +78,18 @@ def get_db_data(db_path_glaucoma, db_path_cataract):
78
  else:
79
  return [], []
80
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  def format_db_data(glaucoma_data, cataract_data):
82
  """ Format the database data for display """
83
  formatted_data = ""
 
78
  else:
79
  return [], []
80
 
81
+ def clear_database(db_path, table_name):
82
+ """Clear all records from the specified table in the database."""
83
+ try:
84
+ conn = sqlite3.connect(db_path)
85
+ cursor = conn.cursor()
86
+ cursor.execute(f"DELETE FROM {table_name}")
87
+ conn.commit()
88
+ conn.close()
89
+ return f"All records from {table_name} table in {db_path} have been deleted."
90
+ except Exception as e:
91
+ return f"Error deleting records from {table_name} table in {db_path}: {str(e)}"
92
+
93
  def format_db_data(glaucoma_data, cataract_data):
94
  """ Format the database data for display """
95
  formatted_data = ""