Ahmed-Raza/phase-3-backend
0
1from sqlalchemy import text
2from database import engine
3
4def delete_user_by_email(email: str):
5 """Delete a user by email"""
6 with engine.connect() as conn:
7 try:
8 result = conn.execute(
9 text('DELETE FROM "user" WHERE email = :email'),
10 {"email": email}
11 )
12 conn.commit()
13 print(f"✅ Deleted user with email: {email}")
14 print(f" Rows affected: {result.rowcount}")
15 except Exception as e:
16 print(f"❌ Error: {e}")
17
18if __name__ == "__main__":
19 email = input("Enter email to delete: ")
20 delete_user_by_email(email)