szaharah commited on
Commit
b19465e
Β·
verified Β·
1 Parent(s): 9ae8356

Update database.py

Browse files
Files changed (1) hide show
  1. database.py +25 -9
database.py CHANGED
@@ -198,6 +198,7 @@ def insert_demo_data():
198
  print("πŸ“š Demo data inserted!")
199
 
200
  def check_database_status():
 
201
  conn = get_connection()
202
  cursor = conn.cursor()
203
 
@@ -207,20 +208,35 @@ def check_database_status():
207
  # Show exact location
208
  db_path = os.path.abspath(DB_NAME)
209
  print(f"πŸ“ FULL PATH: {db_path}")
210
- print(f"πŸ“‹ Tables: {tables}")
211
 
212
  if os.path.exists(db_path):
213
- print(f"βœ… File exists! Size: {os.path.getsize(db_path)} bytes")
 
214
  else:
215
  print(f"❌ File not found!")
 
 
216
 
217
  # Show counts
218
- cursor.execute("SELECT COUNT(*) FROM Student")
219
- student_count = cursor.fetchone()[0]
220
- print(f"πŸ‘₯ Students registered: {student_count}")
221
-
222
- cursor.execute("SELECT COUNT(*) FROM Teacher")
223
- teacher_count = cursor.fetchone()[0]
224
- print(f"πŸ‘¨β€πŸ« Teachers registered: {teacher_count}")
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  conn.close()
 
198
  print("πŸ“š Demo data inserted!")
199
 
200
  def check_database_status():
201
+ """Simple database status check"""
202
  conn = get_connection()
203
  cursor = conn.cursor()
204
 
 
208
  # Show exact location
209
  db_path = os.path.abspath(DB_NAME)
210
  print(f"πŸ“ FULL PATH: {db_path}")
211
+ print(f"πŸ“‹ Tables: {', '.join(tables)}")
212
 
213
  if os.path.exists(db_path):
214
+ file_size = os.path.getsize(db_path)
215
+ print(f"βœ… File exists! Size: {file_size:,} bytes ({file_size/1024:.2f} KB)")
216
  else:
217
  print(f"❌ File not found!")
218
+ conn.close()
219
+ return
220
 
221
  # Show counts
222
+ try:
223
+ cursor.execute("SELECT COUNT(*) FROM Student")
224
+ student_count = cursor.fetchone()[0]
225
+ print(f"πŸ‘₯ Students: {student_count}")
226
+
227
+ cursor.execute("SELECT COUNT(*) FROM Teacher")
228
+ teacher_count = cursor.fetchone()[0]
229
+ print(f"πŸ‘¨β€πŸ« Teachers: {teacher_count}")
230
+
231
+ cursor.execute("SELECT COUNT(*) FROM ImageQuestion")
232
+ question_count = cursor.fetchone()[0]
233
+ print(f"πŸ–ΌοΈ Questions: {question_count}")
234
+
235
+ cursor.execute("SELECT COUNT(*) FROM Feedback")
236
+ feedback_count = cursor.fetchone()[0]
237
+ print(f"πŸ’¬ Feedback: {feedback_count}")
238
+
239
+ except Exception as e:
240
+ print(f"⚠️ Error counting records: {e}")
241
 
242
  conn.close()