Attender / clear_database.py
chualinwei3's picture
Upload 30 files
f742815 verified
Raw
History Blame Contribute Delete
1.23 kB
"""
Clear all database data and reinitialize with fresh tables
"""
from app import app, db
from models import User, Student, Classroom, AttendanceSession, AttendanceRecord
def clear_database():
"""Drop all tables and recreate them"""
with app.app_context():
print("Clearing database...")
print("="*70)
# Drop all tables
db.drop_all()
print("[OK] Dropped all tables")
# Recreate all tables
db.create_all()
print("[OK] Created fresh tables")
print("="*70)
print("Database cleared successfully!")
print("\nAll data has been removed:")
print(" - Users: 0")
print(" - Students: 0")
print(" - Classrooms: 0")
print(" - Attendance Sessions: 0")
print(" - Attendance Records: 0")
print("="*70)
print("\nNext steps:")
print("1. Run: python add_utm_venues.py (to add classrooms)")
print("2. Run: python add_home_venue.py (to add Puteri Court)")
print("3. Register new accounts at: http://localhost:5000/register")
print("="*70)
if __name__ == '__main__':
clear_database()