INNER CODE UNIT · Python

session_factory

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

def session_factory(
    sqla_connection: Connection, sqla_reflection, patch_new_engine
) -> sessionmaker:
    return sessionmaker(bind=sqla_connection)


@fixture
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()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…