fastapi_production_template icon indicating copy to clipboard operation
fastapi_production_template copied to clipboard

how exactly can I use the commit_after flag and is this a way to deal with Transactions?

Open FloareDor opened this issue 6 months ago • 6 comments

can you please explain a bit about the commit_after flag? Furthermore, how do I deal with rollbacks in case an exception occurs in the service layer?

    query: Select | Insert | Update,
    connection: AsyncConnection,
    commit_after: bool = False,
) -> CursorResult:
    result = await connection.execute(query)
    if commit_after:
        await connection.commit()

    return result

do the db changes not get committed if I set commit_after to False?

Thank you so much.

FloareDor avatar Aug 20 '24 11:08 FloareDor