Automated Action 7fdb11e728 Create FastAPI REST API with SQLite database and CRUD operations
- Set up project structure with FastAPI, SQLAlchemy, and Alembic
- Create database models for User and Item
- Implement CRUD operations for all models
- Create API endpoints with validation
- Add health check endpoint
- Configure CORS middleware
- Set up database migrations
- Add comprehensive documentation in README
2025-05-21 08:51:23 +00:00

41 lines
873 B
Python

from datetime import datetime
from typing import Optional
from pydantic import BaseModel, EmailStr, Field
# Shared properties
class UserBase(BaseModel):
email: EmailStr
full_name: Optional[str] = None
is_active: Optional[bool] = True
# Properties to receive on user creation
class UserCreate(UserBase):
password: str = Field(..., min_length=8)
# Properties to receive on user update
class UserUpdate(UserBase):
password: Optional[str] = Field(None, min_length=8)
# Properties shared by models stored in DB
class UserInDBBase(UserBase):
id: int
created_at: datetime
updated_at: Optional[datetime] = None
class Config:
from_attributes = True
# Properties to return to client
class User(UserInDBBase):
pass
# Properties stored in DB but not returned to client
class UserInDB(UserInDBBase):
hashed_password: str