Spaces:
Sleeping
Sleeping
Update database.py
Browse files- 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 |
-
|
|
|
|
| 214 |
else:
|
| 215 |
print(f"β File not found!")
|
|
|
|
|
|
|
| 216 |
|
| 217 |
# Show counts
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|