# Squawk to daryl about unknown HADS sites
import iemdb
HADS = iemdb.connect('hads')
hcursor = HADS.cursor()
hcursor2 = HADS.cursor()

hcursor.execute("""
select nwsli, count(*), max(product) from unknown GROUP by nwsli ORDER by count DESC LIMIT 5
""")
for row in hcursor:
    print '%7s %5s %s' % (row[0], row[1], row[2])
    hcursor2.execute("""
    DELETE from unknown where nwsli = %s
    """, (row[0],))

hcursor.execute("""
 select nwsli, count(*), max(product) from unknown 
 WHERE network ~* 'COOP' GROUP by nwsli ORDER by count DESC LIMIT 5
""")
for row in hcursor:
    print 'COOP %7s %5s %s' % (row[0], row[1], row[2])
    hcursor2.execute("""
    DELETE from unknown where nwsli = %s
    """, (row[0],))

   
HADS.commit()

@@ -148,16 +148,17 @@
 ute(%22%22%22%0A
+ 
 select n
@@ -199,16 +199,44 @@
 unknown 
+%0A where product !~* 'KTIR'%0A 
 GROUP by
@@ -757,8 +757,375 @@
 ommit()%0A
+%0AASOS = iemdb.connect('asos')%0Aacursor = ASOS.cursor()%0Aacursor2 = ASOS.cursor()%0A%0Aacursor.execute(%22%22%22%0A select id, count(*), max(valid) from unknown %0A GROUP by id ORDER by count DESC LIMIT 5%0A%22%22%22)%0Afor row in acursor:%0A    print 'ASOS %257s %255s %25s' %25 (row%5B0%5D, row%5B1%5D, row%5B2%5D)%0A    acursor2.execute(%22%22%22%0A    DELETE from unknown where id = %25s%0A    %22%22%22, (row%5B0%5D,))%0A%0AASOS.commit()%0A%0A

add more networks