
- Add app/db/base.py with SQLAlchemy Base class - Add app/db/session.py with SQLite database connection using absolute path - Add app/models/todo.py with Todo model including all required fields - Add empty __init__.py files for proper package structure
15 lines
572 B
Python
15 lines
572 B
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, Text, Boolean, DateTime
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Todo(Base):
|
|
__tablename__ = "todos"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
completed = Column(Boolean, default=False, nullable=False)
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False) |