Files
ICU_Display_Management/backend/seed.py
T

22 lines
736 B
Python

import asyncio
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
from app.models.user import User, UserRole
from app.core.security import get_password_hash
engine = create_async_engine("sqlite+aiosqlite:///./icu_local.db", echo=False)
AsyncSessionLocal = async_sessionmaker(bind=engine, expire_on_commit=False)
async def seed_user():
async with AsyncSessionLocal() as session:
user = User(
name="Demo Nurse",
email="nurse@hospital.com",
hashed_password=get_password_hash("password123"),
role=UserRole.NURSE
)
session.add(user)
await session.commit()
print("Demo user created successfully.")
asyncio.run(seed_user())