Download scripts/check_db.py from Mohansree/bsure-api: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_db.py
- Command line
-
hf download hf://spaces/Mohansree/bsure-api/scripts/check_db.py
-
curl -L -o check_db.py https://huggingface.co/spaces/Mohansree/bsure-api/resolve/main/scripts/check_db.py
1.16 kB
| from sqlmodel import Session, select | |
| from database import engine | |
| from models import User | |
| def check_users(): | |
| try: | |
| with Session(engine) as session: | |
| users = session.exec(select(User)).all() | |
| print(f"Users found: {len(users)}") | |
| for user in users: | |
| print(f"User: {user.email}, ID: {user.id}") | |
| except Exception as e: | |
| print(f"Error checking users: {e}") | |
| def test_create_user(): | |
| try: | |
| with Session(engine) as session: | |
| print("Attempting to create user...") | |
| # Simulate the register logic | |
| user = User( | |
| email="test_manual@example.com", | |
| password_hash="dummyhash", | |
| full_name="Manual Test" | |
| ) | |
| session.add(user) | |
| session.commit() | |
| print("User created successfully!") | |
| # Clean up | |
| session.delete(user) | |
| session.commit() | |
| except Exception as e: | |
| import traceback | |
| traceback.print_exc() | |
| print(f"Error creating user: {e}") | |
| if __name__ == "__main__": | |
| check_users() | |
| test_create_user() | |