MCPcopy Index your code
hub / github.com/fastapi/full-stack-fastapi-template / init_db

Function init_db

backend/app/core/db.py:15–33  ·  view source on GitHub ↗
(session: Session)

Source from the content-addressed store, hash-verified

13
14
15def init_db(session: Session) -> None:
16 # Tables should be created with Alembic migrations
17 # But if you don't want to use migrations, create
18 # the tables un-commenting the next lines
19 # from sqlmodel import SQLModel
20
21 # This works because the models are already imported and registered from app.models
22 # SQLModel.metadata.create_all(engine)
23
24 user = session.exec(
25 select(User).where(User.email == settings.FIRST_SUPERUSER)
26 ).first()
27 if not user:
28 user_in = UserCreate(
29 email=settings.FIRST_SUPERUSER,
30 password=settings.FIRST_SUPERUSER_PASSWORD,
31 is_superuser=True,
32 )
33 user = crud.create_user(session=session, user_create=user_in)

Callers 2

initFunction · 0.90
dbFunction · 0.90

Calls 1

UserCreateClass · 0.90

Tested by 1

dbFunction · 0.72