def METHOD_NAME(self, connection, alias=None):
    """Registers given connection with optional alias and returns its index.
    Given connection is set to be the :attr:`current` connection.
    If alias is given, it must be a string. Aliases are case and space
    insensitive.
    The index of the first connection after initialization, and after
    :meth:`close_all` or :meth:`empty_cache`, is 1, second is 2, etc.
    """
    self.current = connection
    self._connections.append(connection)
    index = len(self._connections)
    if is_string(alias):
        self._aliases[alias] = index
    return index