def parse_dsn(dsn):
    'Parse connection string into a dictionary of keywords and values.\n       Connection string format:\n           vertica://<user>:<password>@<host>:<port>/<database>?k1=v1&k2=v2&...\n    '
    url = urlparse(dsn)
    if (url.scheme != 'vertica'):
        raise ValueError('Only vertica:// scheme is supported.')
    result = {k: v for (k, v) in (('host', url.hostname), ('port', url.port), ('user', url.username), ('password', url.password), ('database', url.path[1:])) if v}
    for (key, values) in parse_qs(url.query, keep_blank_values=True).items():
        for i in reversed(range(len(values))):
            value = values[i]
            if (value != ''):
                break
        if ((value == '') and (key != 'log_path')):
            continue
        elif (key == 'backup_server_node'):
            continue
        elif (key in ('connection_load_balance', 'use_prepared_statements', 'disable_copy_local', 'ssl', 'autocommit')):
            lower = value.lower()
            if (lower in ('true', 'on', '1')):
                result[key] = True
            elif (lower in ('false', 'off', '0')):
                result[key] = False
        elif (key == 'connection_timeout'):
            result[key] = float(value)
        elif ((key == 'log_level') and value.isdigit()):
            result[key] = int(value)
        else:
            result[key] = value
    return result
Parse connection string into a dictionary of keywords and values.
Connection string format:
    vertica://<user>:<password>@<host>:<port>/<database>?k1=v1&k2=v2&...
def parse_dsn(dsn):
    'Parse connection string into a dictionary of keywords and values.\n       Connection string format:\n           vertica://<user>:<password>@<host>:<port>/<database>?k1=v1&k2=v2&...\n    '
    url = urlparse(dsn)
    if (url.scheme != 'vertica'):
        raise ValueError('Only vertica:// scheme is supported.')
    result = {k: v for (k, v) in (('host', url.hostname), ('port', url.port), ('user', url.username), ('password', url.password), ('database', url.path[1:])) if v}
    for (key, values) in parse_qs(url.query, keep_blank_values=True).items():
        for i in reversed(range(len(values))):
            value = values[i]
            if (value != ):
                break
        if ((value == ) and (key != 'log_path')):
            continue
        elif (key == 'backup_server_node'):
            continue
        elif (key in ('connection_load_balance', 'use_prepared_statements', 'disable_copy_local', 'ssl', 'autocommit')):
            lower = value.lower()
            if (lower in ('true', 'on', '1')):
                result[key] = True
            elif (lower in ('false', 'off', '0')):
                result[key] = False
        elif (key == 'connection_timeout'):
            result[key] = float(value)
        elif ((key == 'log_level') and value.isdigit()):
            result[key] = int(value)
        else:
            result[key] = value
    return result