def METHOD_NAME(uri):
    """
    Removes the last part of the path from a URI and returns it separately.
    Generally useful for connecting to the URI but at a less specific level than the one given,
    Eg, when given a URI of the form SCHEME://HOST/DBNAME/DBSCHEMA, we want to connect to SCHEME://HOST/DBNAME
    and then specify the DBSCHEMA separately in each query.
    """
    url = urlsplit(uri)
    url_path = PurePosixPath(url.path)
    last_part = url_path.name
    modified_url_path = str(url_path.parent)
    modified_url = urlunsplit(
        [url.scheme, url.netloc, modified_url_path, url.query, ""]
    )
    return (modified_url, last_part)