Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Feb 15th, 2013  |  syntax: Python  |  size: 0.72 KB  |  views: 22  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. conn = pymysql.connect(host='127.0.0.1', port=3306, user='***', passwd='***', db='***')
  2. cur = conn.cursor()
  3.  
  4. cur.execute("SELECT preset, datespec, timespec, priority FROM schedule WHERE `enabled`='1' ORDER BY priority DESC")
  5.  
  6. for r in cur.fetchall():
  7.         if datecheck(r[1],r[2]) == 1:
  8.                 execstring = "UPDATE preset SET `enabled`=1, `priority`=" + str(r[3]) + " WHERE id=" + str(r[0])
  9.                 #execstring = "UPDATE preset SET enabled=1, priority=20 WHERE id=0"
  10.                 print execstring
  11.                 cur.execute(execstring)
  12.                 print cur.fetchall()
  13.                 print "Enabled"
  14.         else:
  15.                 execstring = "UPDATE preset SET `enabled`=0 WHERE id=" + str(r[0])
  16.                 print execstring
  17.                 cur.execute(execstring)
  18.                 print cur.fetchall()
  19.                 print "Disabled"
  20.  
  21. conn.commit()
clone this paste RAW Paste Data