All pastes #163420 Raw Edit

mysql_num_rows issue

public text v1 · immutable
·published 2006-09-07 14:47 UTC
rendered paste body
def RemoveCacheEntry():
  syslog.syslog(syslog.LOG_NOTICE, 'removing cache entries')
  dbh = psycopg.connect(DSN)
  dbh.autocommit(0)
  curs = dbh.cursor()

  first_row = 1;
  curs.execute("SELECT id, port_id, category, port FROM cache_clearing_ports ORDER BY id")
  for row in curs.dictfetchall():
    if (first_row):
      min_id = row['id']
      max_id = row['id']
      first_row = 0

    min_id = min(row['id'], min_id)
    max_id = max(row['id'], max_id)
    # other processing goes here

    syslog.syslog(syslog.LOG_NOTICE, 'removing %s/%s' % (row['category'], row['port']))

  syslog.syslog(syslog.LOG_NOTICE, 'removing entries between %s and %s' % (min_id, max_id))
#  print "finished with RemoveCacheEntry"
  return