Demo entry 6632078

11111111111

   

Submitted by anonymous on Jul 21, 2017 at 04:18
Language: ANTLR With Ruby Target. Code size: 1.9 kB.

# !/usr/bin/python
# -*- coding: UTF-8 -*-

import MySQLdb
import redis

try:
    mysql_conn = MySQLdb.connect(host="192.168.16.68", user='root', passwd='duamiawen&&&&', db='yqms2',charset='utf8')
    mysql_cursor = mysql_conn.cursor()
except Exception as e:
    print 'mysql connect failed', e

try:
    redis_conn = redis.StrictRedis(host='192.168.110.51', port=6379, db=9)
except Exception as e:
    print 'redis connect failed', e


def get_id():
    n = 1
    try:
        sql = '''SELECT KU_ID FROM WK_T_USERSERVICE WHERE KU_USERSTATUS != "2"'''
        mysql_cursor.execute(sql)
        ids = mysql_cursor.fetchall()
        for each in ids:
            id_num = each[0]
            print id_num,'###########################################################################',n
            n+=1
            try:
                sql = '''SELECT KK_EVENT FROM WK_T_KEYWS WHERE KU_ID = "%s"''' % id_num
                mysql_cursor.execute(sql)
                keywords_all = mysql_cursor.fetchall()
                for keywords_text in keywords_all:
                    keywords_text = keywords_text[0]
                    # print keywords_text
                    keywords_list = keywords_text.split()
                    # print keywords_list
                    for item in keywords_list:
                        print item
                        if not item == "":
                            number = redis_conn.hget("jjx_event", item)
                            print number
                            if not number:
                                number = 1
                            else:
                                number = int(number) + 1
                            redis_conn.hset('jjx_event', item, number)

            except Exception as e:
                print 'get keywords failed', e


    except Exception as e:
        print 'get id failed', e


get_id()

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).