Automated Action 10f64177dc Create REST API with FastAPI and SQLite
- Set up FastAPI application with CORS and authentication
- Implement user registration and login with JWT tokens
- Create SQLAlchemy models for users and items
- Add CRUD endpoints for item management
- Configure Alembic for database migrations
- Add health check endpoint
- Include comprehensive API documentation
- Set up proper project structure with routers and schemas
2025-07-17 16:54:25 +00:00

22 lines
512 B
Python

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from pathlib import Path
DB_DIR = Path("/app/storage/db")
DB_DIR.mkdir(parents=True, exist_ok=True)
SQLALCHEMY_DATABASE_URL = f"sqlite:///{DB_DIR}/db.sqlite"
engine = create_engine(
SQLALCHEMY_DATABASE_URL,
connect_args={"check_same_thread": False}
)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()