(username, password, location, source)
return insert('INSERT INTO credentials VALUES (?,?,?,?,?)',
                    (username, password, location, source_idx, _timestamp()))
Insert credentials into the database.  If the host is not found,
        insert the source into the host table with a null mac/hostname,
        which can be updated later.

        Source should be an IP address of the source the credentials were
        coming from.
        Location is where the credentials were being used at.
Insert credentials into the database.  If the host is not found,
        insert the source into the host table with a null mac/hostname,
        which can be updated later.
Insert credentials into the database . If the host is not found insert the source into the host table with a null mac / hostname which can be updated later .
def dbcredentials(username, password, location, source):
    """ Insert credentials into the database.  If the host is not found,
        insert the source into the host table with a null mac/hostname,
        which can be updated later.

        Source should be an IP address of the source the credentials were
        coming from.
        Location is where the credentials were being used at.
    """
    source_idx = None
    while source_idx is None: 
        source_idx = fetch('SELECT ROWID FROM host WHERE ip = ?', (source,))
        if len(source_idx) > 0:
           source_idx = source_idx[0][0]
        else:
            dbhost(None, source, None)
            source_idx = None

    return insert('INSERT INTO credentials VALUES (?,?,?,?,?)',
                    (username, password, location, source_idx, _timestamp()))
def dbcredentials ( username , password , location , source ) : source_idx = None while source_idx is None : source_idx = fetch ( 'SELECT ROWID FROM host WHERE ip = ?' , ( source , ) ) if len ( source_idx ) > 0 : source_idx = source_idx [ 0 ] [ 0 ] else : dbhost ( None , source , None ) source_idx = None return insert ( 'INSERT INTO credentials VALUES (?,?,?,?,?)' , ( username , password , location , source_idx , _timestamp ( ) ) )