Converts the ``connection_string`` into a three elements tuple
    ``(scheme, host, params)`` where ``scheme`` is a string, ``host`` could
    be a string or a two elements tuple (for a tcp address) and ``params`` a
    dictionary of parameters. The ``default_port`` parameter can be used to
    set the port if a port is not available in the ``connection_string``.

    For example::

        >>> parse_connection_string('http://127.0.0.1:9080')
        ('http', ('127.0.0.1', 9080), {})

    and this example::

        >>> parse_connection_string('redis://127.0.0.1:6379?db=3&password=bla')
        ('redis', ('127.0.0.1', 6379), {'db': '3', 'password': 'bla'})

def parse_connection_string(connection_string, default_port=8000):
    """Converts the ``connection_string`` into a three elements tuple
    ``(scheme, host, params)`` where ``scheme`` is a string, ``host`` could
    be a string or a two elements tuple (for a tcp address) and ``params`` a
    dictionary of parameters. The ``default_port`` parameter can be used to
    set the port if a port is not available in the ``connection_string``.

    For example::

        >>> parse_connection_string('http://127.0.0.1:9080')
        ('http', ('127.0.0.1', 9080), {})

    and this example::

        >>> parse_connection_string('redis://127.0.0.1:6379?db=3&password=bla')
        ('redis', ('127.0.0.1', 6379), {'db': '3', 'password': 'bla'})
    """
    if '://' not in connection_string:
        connection_string = 'dummy://%s' % connection_string
    scheme, host, path, query, fragment = urlsplit(connection_string)
    if not scheme and not host:
        host, path = path, ''
    elif path and not query:
        query, path = path, ''
        if query:
            if query.find('?'):
                path = query
            else:
                query = query[1:]
    if path:
        raise ValueError("Address must not have a path. Found '%s'" % path)
    if query:
        params = dict(parse_qsl(query))
    else:
        params = {}
    if scheme == 'dummy':
        scheme = ''
    return scheme, parse_address(host, default_port), params