def update_requestdomain(domain):
    # Update Database here
    global request_batch
    global processed_batches
    global DUT_IP
    global contacted_hosts
    global current_dns_records
    if str(domain) == str(request_batch.get_requesturl()):
        print "UDP packet doubling detected!: %s" % (domain)
        return
    print "currently processing: %s" % (domain)
    if request_batch._requestURL != "":  # check wheter the requestbatch has been touched before
        processed_batches.append(request_batch)
    # sets the extracted DNS records to the data structure
    for conn in request_batch._active_connections:
        for dns in current_dns_records:
            if conn._dst_IP in dns:
                conn._DNS = dns

    current_dns_records = []
    request_batch = RequestBatch()
    request_batch.set_requesturl(str(domain))
    contacted_hosts = []

    if "| MOBILE |" in str(domain):
        DUT_IP = "10.0.0.23"

    if "| DESKTOP |" in str(domain):
        DUT_IP = "10.0.0.42"
def read_from_sql(sql_statement, batches):
    conn = sqlite3.connect(opts.file)
    cursor = conn.cursor()
    cursor.execute(sql_statement)

    for entry in cursor.fetchall():
        batch = RequestBatch()
        batch.set_filename(entry[1])
        batch.set_requesturl(entry[2])
        batch.set_getrequests(entry[3])
        batch.set_dnsrequests(entry[4])
        batch.set_downstreamvolume(entry[5])
        batch.set_upstreamvolume(entry[6])
        batch.set_nr_of_host_contacts(entry[7])
        batch.set_connection_count(entry[8])
        batch.set_nr_of_web_bugs(entry[9])

        batches.append(batch)
    conn.close()