'Get the connection specified by the given alias or index..
If ``alias_or_index`` is ``None``, returns the current connection
if it is active, or raises an error if it is not.
Alias is whatever was given to :meth:`register` method and indices
are returned by it. Index can be given either as an integer or
as a string that can be converted to an integer. Raises an error
if no connection with the given index or alias found.'

def get_connection(self, alias_or_index=None):

    if (alias_or_index is None):
        if (not self):
            self.current.raise_error()
        return self.current
    try:
        index = self._resolve_alias_or_index(alias_or_index)
    except ValueError:
        raise RuntimeError(("Non-existing    index    or    alias    '%s'." % alias_or_index))
    return self._connections[(index - 1)]
