18 lines
707 B
Python
18 lines
707 B
Python
from sqlalchemy import create_engine, Column, Integer, String, Date
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
DATABASE_URL = "sqlite:///./todos.db"
|
|
engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False})
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
Base = declarative_base()
|
|
|
|
class Task(Base):
|
|
__tablename__ = "tasks"
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
title = Column(String(255), nullable=False)
|
|
description = Column(String(1000))
|
|
due_date = Column(Date, nullable=False)
|
|
status = Column(String(20), default="pending")
|
|
|
|
Base.metadata.create_all(bind=engine) |