SessionMiddleware (starlette/config.py)

advanced-alchemy · advanced_alchemy/extensions/starlette/config.py · python · MIT
database

ASGI middleware for Starlette to manage SQLAlchemy database session lifecycles.

# Source: https://github.com/litestar-org/advanced-alchemy | License: MIT | Copyright 2024 Litestar Organization
# Provided via justclaw.it.com; keep this notice with the code.
"""Configuration classes for Starlette integration.

This module provides configuration classes for integrating SQLAlchemy with Starlette applications,
including both synchronous and asynchronous database configurations.
"""

import contextlib
import logging
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, Callable, Optional, Union, cast

from sqlalchemy.exc import OperationalError
from starlette.concurrency import run_in_threadpool  # pyright: ignore[reportUnknownVariableType]
from starlette.requests import Request
from typing_extensions import Literal

from advanced_alchemy.base impo

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key