def urlbuild(scheme, path, username=None, password=None, hostname=None,
    port=None):
    """Builds a URL to pass into :py:func:`sqlalchemy.create_engine`

    dialect+driver://username:password@host:port/database
    """
    netloc = []
    if username:
        netloc.append(username)
    if password:
        netloc.append(':')
        netloc.append(password)
    if username or password:
        netloc.append('@')
    if hostname:
        netloc.append(hostname)
    if port:
        netloc.append(':')
        netloc.append(port)
    return '{scheme}://{netloc}/{path}'.format(scheme=scheme, netloc=''.
        join(netloc), path=path)
