INNER CODE UNIT · Python

session

dialoguemd/fastapi-sqla · fastapi_sqla/_pytest_plugin.py:132

def session(session_factory: sessionmaker) -> Generator[Session]:
    """Sqla session to use when creating db fixtures.

    While it does not write any record in DB, the application will still be able to
    access any record committed with that session.
    """
    session: Session = session_factory()
    yield session
    session.close()


def format_async_async_sqlalchemy_url(url: str) -> str:
    scheme, location, path, query, fragment = urlsplit(url)
    bare_scheme = scheme.split("+")[0]
    return urlunsplit([f"{bare_scheme}+asyncpg", location, path, query, fragment])


@fixture(scope="session")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…