(connection: BaseDatabaseWrapper, **kwargs: Any)
Rather than use the documented API of the `execute_wrapper()` context
    manager, directly insert the hook. This is done because:
    1. Deleting the context manager closes it, so it's not possible to enter it
       here and not exit it, unless we store it forever in some variable.
    2. We want to be idempotent and only install the hook once.
Rather than use the documented API of the `execute_wrapper()` context
    manager, directly insert the hook. This is done because:
    1. Deleting the context manager closes it, so it's not possible to enter it
       here and not exit it, unless we store it forever in some variable.
    2. We want to be idempotent and only install the hook once.
Rather than use the documented API of the execute_wrapper () context manager directly insert the hook . This is done because : 1 . Deleting the context manager closes it so it s not possible to enter it here and not exit it unless we store it forever in some variable . 2 . We want to be idempotent and only install the hook once .
def install_rewrite_hook(connection: BaseDatabaseWrapper, **kwargs: Any) -> None:
    """
    Rather than use the documented API of the `execute_wrapper()` context
    manager, directly insert the hook. This is done because:
    1. Deleting the context manager closes it, so it's not possible to enter it
       here and not exit it, unless we store it forever in some variable.
    2. We want to be idempotent and only install the hook once.
    """
    if connection.vendor != "mysql":
        return
    if rewrite_hook not in connection.execute_wrappers:  # pragma: no branch
        connection.execute_wrappers.insert(0, rewrite_hook)
def install_rewrite_hook ( connection : BaseDatabaseWrapper , * * kwargs : Any ) -> None : if connection . vendor != "mysql" : return if rewrite_hook not in connection . execute_wrappers : # pragma: no branch connection . execute_wrappers . insert ( 0 , rewrite_hook )