Spaces:
Running
Running
Download scripts/seed_db.py from fallingbody/Mockai: direct link, hf CLI and curl.
- Browser
- Download file 763 Bytes
-
https://huggingface.co/spaces/fallingbody/Mockai/resolve/main/scripts/seed_db.py
- Command line
-
hf download hf://spaces/fallingbody/Mockai/scripts/seed_db.py
-
curl -L -o seed_db.py https://huggingface.co/spaces/fallingbody/Mockai/resolve/main/scripts/seed_db.py
763 Bytes
| from uuid import uuid4 | |
| from app.core.logger import get_logger | |
| from app.persistence.database.session import get_db_session | |
| from app.persistence.database.models.user_model import UserModel | |
| logger = get_logger(__name__) | |
| def seed_users(): | |
| db = get_db_session() | |
| try: | |
| if db.query(UserModel).count() > 0: | |
| logger.info("Users already exist, skipping seed") | |
| return | |
| users = [ | |
| UserModel( | |
| id=uuid4(), | |
| name="Test Candidate", | |
| email="test.candidate@example.com", | |
| ) | |
| ] | |
| db.add_all(users) | |
| db.commit() | |
| logger.info("Database seeded successfully") | |
| finally: | |
| db.close() | |
| if __name__ == "__main__": | |
| seed_users() | |