
- Implemented project structure with FastAPI framework - Set up SQLite database with SQLAlchemy ORM - Created Alembic for database migrations - Implemented Item model and CRUD operations - Added health check endpoint - Added error handling - Configured API documentation with Swagger UI generated with BackendIM... (backend.im)
15 lines
593 B
Python
15 lines
593 B
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Text
|
|
from sqlalchemy.sql import func
|
|
from .database import Base
|
|
|
|
|
|
class Item(Base):
|
|
__tablename__ = "items"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String(100), nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
price = Column(Integer, nullable=False) # Price in cents
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now()) |