1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import pymysql
import traceback
import logging
import json
from vest.request.auto_request import host, user, db, passwd
from libs.cache import redis_client
from libs.error import logging_exception
def get_data():
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute("select user_id from user_extra where is_shadow = 1 ")
data = cursor.fetchall()
user_id = list(data)
logging.info("Database version : %s " % user_id)
user_id_list = []
if user_id:
for i in user_id:
cursor.execute("select user_id from topic where user_id = " + str(
i[0]) + " group by user_id having count(user_id) >5")
data = cursor.fetchall()
user_id = list(data)
if len(user_id):
user_id_list.append(user_id[0])
pc.close()
return user_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None
def auto_user_id():
try:
data = get_data()
file = open("/srv/apps/physical/vest/data/get_user_id.txt", "w")
if data:
for i in data:
file.write(str(i[0]))
file.write("\n")
redis_client.set("get_user_id_data", json.dumps(data))
except:
logging_exception()
logging.error("index_first:%s" % traceback.format_exc())