CoolFace
Apppublic

Ahmed-Raza/phase-3-backend

sourceHugging Faceupdated 8mo agoView on Hugging Face
0likes
delete_user.py20 linesDownload Raw Back to root
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)