
Create a simple Todo API with FastAPI and SQLite with CRUD functionality, health check, error handling, and API documentation.
19 lines
583 B
Python
19 lines
583 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, Column, DateTime, Integer, String, Text
|
|
|
|
from app.database.session import Base
|
|
|
|
|
|
class Todo(Base):
|
|
"""
|
|
SQLAlchemy model for todo items.
|
|
"""
|
|
__tablename__ = "todos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(100), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
completed = Column(Boolean, default=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow) |