INNER CODE UNIT · Python

db_url

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

def db_url(db_host: str, db_user: str) -> str:
    """Default db url used by depending fixtures.

    db url example postgresql://{db_user}@{db_host}/postgres
    """
    return f"postgresql://{db_user}@{db_host}/postgres"


@fixture(scope="session")
def engine(db_url: str) -> Engine:
    return create_engine(db_url)


@fixture(scope="session")
def sqla_connection(engine: Engine) -> Generator[Connection]:
    with engine.connect() as connection:
        yield connection

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…