This commit is contained in:
2026-02-26 19:18:58 +05:00
commit 2fedc1ac18
18 changed files with 445 additions and 0 deletions

19
database.py Normal file
View File

@@ -0,0 +1,19 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, declarative_base
SQLALCHEMY_DATABASE_URL = "sqlite:///./tasks.db"
# connect_args={"check_same_thread": False} is required for SQLite in FastAPI
engine = create_engine(
SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
# Dependency
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()