
- Set up project structure and dependencies - Implement Todo model with SQLAlchemy - Configure SQLite database connection - Create Alembic migration scripts - Implement RESTful API endpoints for CRUD operations - Add health check endpoint - Update README with documentation generated with BackendIM... (backend.im)
18 lines
432 B
Python
18 lines
432 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
from app.core.config import settings
|
|
|
|
engine = create_engine(
|
|
settings.SQLALCHEMY_DATABASE_URL,
|
|
connect_args={"check_same_thread": False} # Needed for SQLite
|
|
)
|
|
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
|
|
|
# Dependency
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close() |