Automated Action d84f05f712 Create FastAPI REST API service with user management
- Set up FastAPI application with proper project structure
- Configure SQLite database with SQLAlchemy ORM
- Implement user model with CRUD operations
- Add Alembic for database migrations
- Create comprehensive API endpoints for user management
- Configure CORS middleware for cross-origin requests
- Add health check endpoint and service information
- Set up Ruff for code linting and formatting
- Update README with complete documentation

Co-Authored-By: BackendIM <noreply@backendim.com>
2025-06-18 07:32:46 +00:00

24 lines
522 B
Python

from pathlib import Path
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
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()