gen_cur_category.py 472 B

123456789101112131415161718
  1. import time
  2. import json
  3. import random
  4. import dataset
  5. #r = redis.Redis(host='db.ptt.cx', port=6379, db=1)
  6. #p = r.pubsub(ignore_subscribe_messages=True)
  7. db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
  8. table=db['cur_category']
  9. #cursor=db.query('select id,kw from gtrends where name = "'+site+'" order by rand() limit 1')
  10. category='hhh-faq'
  11. table.upsert({'category':category,'id':1},keys=['id'])
  12. #table.insert({'category':category},)