SHARE
TWEET

Untitled

a guest Feb 15th, 2013 23 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top