Commit fecd87b1 authored by lixiaofang's avatar lixiaofang

try except

parent c4d39acd
This diff is collapsed.
...@@ -140,13 +140,17 @@ def get_commnet_id(numtime): ...@@ -140,13 +140,17 @@ def get_commnet_id(numtime):
user_id = [] user_id = []
for i in data_id: for i in data_id:
user_id.append(i) if i[0] is not None:
user_id.append(i)
for i in data1_id: for i in data1_id:
user_id.append(i) if i[0] is not None:
user_id.append(i)
for i in data2_id: for i in data2_id:
user_id.append(i) if i[0] is not None:
user_id.append(i)
for i in data3_id: for i in data3_id:
user_id.append(i) if i[0] is not None:
user_id.append(i)
print("Database version : %s " % user_id) print("Database version : %s " % user_id)
......
...@@ -140,15 +140,17 @@ def time_conv(numtime): ...@@ -140,15 +140,17 @@ def time_conv(numtime):
return None return None
def get_data(numtime): def get_data(numtime):
try: try:
db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306) db = pymysql.connect(host="rm-2ze5k2we69904787l.mysql.rds.aliyuncs.com", user='work', passwd='Gengmei123', db="alpha", port=3306)
cursor = db.cursor() cursor = db.cursor()
cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" %numtime) cursor.execute("SELECT distinct(user_id) FROM topic WHERE create_time LIKE '%%%%%s%%%%'" %numtime)
data = cursor.fetchall() data = cursor.fetchall()
user_id = list(data) user_id = list(data)
logging.info("Database version : %s " % data) logging.info("Database version : %s " % data)
db.close() db.close()
return user_id return user_id
except: except:
logging.error("catch exception,get_data:%s" % traceback.format_exc()) logging.error("catch exception,get_data:%s" % traceback.format_exc())
return None return None
...@@ -194,9 +196,9 @@ if __name__ == "__main__": ...@@ -194,9 +196,9 @@ if __name__ == "__main__":
#topic #topic
for i in time_list: for i in range(len(time_list)):
numtime = time_conv(i) numtime = time_conv(time_list[i])
user_id = get_data(numtime) user_id = get_data(numtime)
......
x=(None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (695,), (696,), (695,), (698,), (699,), (700,), (695,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (709,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (678,), (None,), (709,), (709,), (709,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (732,), (730,), (729,), (None,), (173,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,), (None,)
for i in x:
if i[0] is not None:
print(i[0])
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment