Automated Action d1c05cbd6e Implement Task Manager API with FastAPI and SQLite
- Set up project structure and dependencies
- Create database models for tasks and users with SQLAlchemy
- Configure Alembic for database migrations
- Implement authentication system with JWT tokens
- Create CRUD API endpoints for tasks and users
- Add health check endpoint
- Update README with documentation
2025-06-12 18:14:56 +00:00

26 lines
942 B
Python

from sqlalchemy.orm import Session
from app import crud, schemas
from app.db import base # noqa: F401
# make sure all SQL Alchemy models are imported (app.db.base) before initializing DB
# otherwise, SQL Alchemy might fail to initialize relationships properly
# for more details: https://github.com/tiangolo/full-stack-fastapi-postgresql/issues/28
def init_db(db: Session) -> None:
# Tables should be created with Alembic migrations
# But if you don't want to use migrations, create
# the tables uncommenting the next line
# Base.metadata.create_all(bind=engine)
# Create a superuser if it doesn't exist
user = crud.user.get_by_email(db, email="admin@example.com")
if not user:
user_in = schemas.UserCreate(
email="admin@example.com",
username="admin",
password="adminpassword",
is_superuser=True,
)
crud.user.create(db, obj_in=user_in)