(mac, ip, hostname)
return source_idx
insert basic host information into the database
insert basic host information into the database
insert basic host information into the database
def dbhost(mac, ip, hostname):
    """ insert basic host information into the database
    """
    source_idx = None
    while source_idx is None:
        source_idx = fetch('SELECT ROWID FROM host WHERE ip = ?', (ip,))
        if len(source_idx) > 0:
            # the host is already in the database; update the mac/hostname
            insert('UPDATE host SET mac = ?, hostname = ? WHERE ip = ?',
                        (mac, hostname))
            source_idx = None
        else:
            source_idx = insert('INSERT INTO host VALUES (?,?,?);', (mac, ip, hostname))
    return source_idx
def dbhost ( mac , ip , hostname ) : source_idx = None while source_idx is None : source_idx = fetch ( 'SELECT ROWID FROM host WHERE ip = ?' , ( ip , ) ) if len ( source_idx ) > 0 : # the host is already in the database; update the mac/hostname insert ( 'UPDATE host SET mac = ?, hostname = ? WHERE ip = ?' , ( mac , hostname ) ) source_idx = None else : source_idx = insert ( 'INSERT INTO host VALUES (?,?,?);' , ( mac , ip , hostname ) ) return source_idx