def atomic(connection_name: Optional[str] = None) -> Callable:
    """
    Transaction decorator.

    You can wrap your function with this decorator to run it into one transaction.
    If error occurs transaction will rollback.

    :param connection_name: name of connection to run with, optional if you have only
                            one db connection
    """

    def wrapper(func):
        @wraps(func)
        async def wrapped(*args, **kwargs):
            connection = _get_connection(connection_name)
            async with connection._in_transaction():
                return await func(*args, **kwargs)

        return wrapped

    return wrapper
def atomic ( connection_name : Optional [ str ] = None ) -> Callable : def wrapper ( func ) : @ wraps ( func ) async def wrapped ( * args , ** kwargs ) : connection = _get_connection ( connection_name ) async with connection . _in_transaction ( ) : return await func ( * args , ** kwargs ) return wrapped return wrapper
Transaction decorator.

    You can wrap your function with this decorator to run it into one transaction.
    If error occurs transaction will rollback.

    :param connection_name: name of connection to run with, optional if you have only
                            one db connection