ankit5566 commited on
Commit
107df9d
·
verified ·
1 Parent(s): 6652405

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -37
app.py CHANGED
@@ -675,46 +675,46 @@ Provide the nutritional information in the following JSON format only:
675
  custom_timestamp=custom_timestamp
676
  )
677
 
678
- # Add a section to clear database
679
- st.header("Database Management")
680
- if st.button("🗑️ Clear All Records"):
681
- try:
682
- conn = sqlite3.connect("nutrition_data.db")
683
- cursor = conn.cursor()
684
- cursor.execute("DROP TABLE IF EXISTS records")
685
- conn.commit()
686
 
687
- # Recreate the table
688
- cursor.execute('''CREATE TABLE IF NOT EXISTS records (
689
- id INTEGER PRIMARY KEY AUTOINCREMENT,
690
- image BLOB,
691
- timestamp TEXT,
692
- macronutrients TEXT,
693
- micronutrients TEXT,
694
- food_items TEXT,
695
- improvements TEXT,
696
- goal TEXT
697
- )''')
698
- conn.commit()
699
- conn.close()
700
 
701
- # Clear session state as well
702
- if 'analysis_done' in st.session_state:
703
- st.session_state.analysis_done = False
704
- if 'initial_result' in st.session_state:
705
- st.session_state.initial_result = None
706
- if 'image_bytes' in st.session_state:
707
- st.session_state.image_bytes = None
708
- if 'base64_image' in st.session_state:
709
- st.session_state.base64_image = None
710
- if 'last_uploaded_file' in st.session_state:
711
- st.session_state.last_uploaded_file = None
712
 
713
- st.success("✅ Database cleared successfully! You can now start adding new records.")
714
- st.rerun()
715
- except Exception as e:
716
- st.error(f"Error clearing database: {str(e)}")
717
- st.write("Debug info:", e)
718
 
719
  def display_records():
720
  try:
 
675
  custom_timestamp=custom_timestamp
676
  )
677
 
678
+ # # Add a section to clear database
679
+ # st.header("Database Management")
680
+ # if st.button("🗑️ Clear All Records"):
681
+ # try:
682
+ # conn = sqlite3.connect("nutrition_data.db")
683
+ # cursor = conn.cursor()
684
+ # cursor.execute("DROP TABLE IF EXISTS records")
685
+ # conn.commit()
686
 
687
+ # # Recreate the table
688
+ # cursor.execute('''CREATE TABLE IF NOT EXISTS records (
689
+ # id INTEGER PRIMARY KEY AUTOINCREMENT,
690
+ # image BLOB,
691
+ # timestamp TEXT,
692
+ # macronutrients TEXT,
693
+ # micronutrients TEXT,
694
+ # food_items TEXT,
695
+ # improvements TEXT,
696
+ # goal TEXT
697
+ # )''')
698
+ # conn.commit()
699
+ # conn.close()
700
 
701
+ # # Clear session state as well
702
+ # if 'analysis_done' in st.session_state:
703
+ # st.session_state.analysis_done = False
704
+ # if 'initial_result' in st.session_state:
705
+ # st.session_state.initial_result = None
706
+ # if 'image_bytes' in st.session_state:
707
+ # st.session_state.image_bytes = None
708
+ # if 'base64_image' in st.session_state:
709
+ # st.session_state.base64_image = None
710
+ # if 'last_uploaded_file' in st.session_state:
711
+ # st.session_state.last_uploaded_file = None
712
 
713
+ # st.success("✅ Database cleared successfully! You can now start adding new records.")
714
+ # st.rerun()
715
+ # except Exception as e:
716
+ # st.error(f"Error clearing database: {str(e)}")
717
+ # st.write("Debug info:", e)
718
 
719
  def display_records():
720
  try: