Ejemplo n.º 1
0
def odbc_conn_string(conn, strip_password = False):
    conn_params = dict(conn.parameterValues)
    conn_params.update(get_connection_parameters(conn))

    connection_string_template = conn.driver.connectionStringTemplate or 'DRIVER={%driver%};SERVER=%host%;PORT=%port%;DATABASE={%database%};UID=%username%;PWD={%password%}'
    connstring = replace_string_parameters(connection_string_template, conn_params)
    if strip_password:
        connstring = re.sub("(PWD={[^;]}*|PWD=[^;]*)", "", connstring).rstrip(";")
    return connstring
Ejemplo n.º 2
0
def odbc_conn_string(conn, strip_password = False):
    conn_params = dict(conn.parameterValues)
    conn_params.update(get_connection_parameters(conn))

    connection_string_template = conn.driver.connectionStringTemplate or 'DRIVER={%driver%};SERVER=%host%;PORT=%port%;DATABASE={%database%};UID=%username%;PWD={%password%}'
    connstring = replace_string_parameters(connection_string_template, conn_params)
    if strip_password:
        connstring = re.sub("(PWD={[^;]}*|PWD=[^;]*)", "", connstring).rstrip(";")
    return connstring
def request_password(connection, forget_old = False):
    # Get the password:
    for param in connection.driver.parameters:
        if param.paramType in ('keychain', 'password'):
            if param.paramType == 'keychain':
                connection_params = get_connection_parameters(connection, do_not_transform=True)
                storage_key_format = param.paramTypeDetails['storageKeyFormat']
                username, storage_string = replace_string_parameters(storage_key_format, connection_params).split('::', 1)
                accepted, passwd = mforms.Utilities.find_or_ask_for_password('Enter password for user ' + username, storage_string, username, forget_old)
                if accepted:
                    return passwd
            else: # Plain password field
                return connection.parameterValues['password']
            break
    return None
def request_password(connection, forget_old = False):
    # Get the password:
    for param in connection.driver.parameters:
        if param.paramType in ('keychain', 'password'):
            if param.paramType == 'keychain':
                connection_params = get_connection_parameters(connection, do_not_transform=True)
                storage_key_format = param.paramTypeDetails['storageKeyFormat']
                username, storage_string = replace_string_parameters(storage_key_format, connection_params).split('::', 1)
                accepted, passwd = mforms.Utilities.find_or_ask_for_password('Enter password for user ' + username, storage_string, username, forget_old)
                if accepted:
                    return passwd
            else: # Plain password field
                return connection.parameterValues['password']
            break
    return None