Commit 76c111ee authored by 张彦钊's avatar 张彦钊

增加捕捉异常

parent aaf2c17d
...@@ -24,12 +24,19 @@ def get_video_id(cache_video_id): ...@@ -24,12 +24,19 @@ def get_video_id(cache_video_id):
db = pymysql.connect(host=LOCAL_EAGLE_HOST, port=4000, user='root', db='eagle') db = pymysql.connect(host=LOCAL_EAGLE_HOST, port=4000, user='root', db='eagle')
cursor = db.cursor() cursor = db.cursor()
sql = "select diary_id from feed_diary_boost;" sql = "select diary_id from feed_diary_boost;"
cursor.execute(sql) try:
result = cursor.fetchall() cursor.execute(sql)
df = pd.DataFrame(list(result)) result = cursor.fetchall()
df = pd.DataFrame(list(result))
except Exception:
print("发生异常", Exception)
df = pd.DataFrame()
finally:
db.close()
print("videio_id 预览") print("videio_id 预览")
print(df.head(1)) print(df.head(1))
db.close()
if df.empty: if df.empty:
return cache_video_id return cache_video_id
else: else:
......
...@@ -15,6 +15,9 @@ pip install redis ...@@ -15,6 +15,9 @@ pip install redis
pip install numpy pip install numpy
sudo apt-get install python3-dev sudo apt-get install python3-dev
pip install pandas pip install pandas
pip install datetime
pip install git+https://github.com/Supervisor/supervisor pip install git+https://github.com/Supervisor/supervisor
问题: 问题:
#安装pandas出错:Python.h: No such file or directory #安装pandas出错:Python.h: No such file or directory
......
...@@ -29,7 +29,7 @@ def get_active_users(flag,path,differ): ...@@ -29,7 +29,7 @@ def get_active_users(flag,path,differ):
df = con_sql(sql) df = con_sql(sql)
else: else:
db = pymysql.connect(host='192.168.15.12', port=4000, user='root', db='jerry_test') db = pymysql.connect(host='192.168.15.12', port=4000, user='root', db='jerry_test')
# sql = "select device_id,city_id from user_active_time" sql = "select device_id,city_id from user_active_time"
cursor = db.cursor() cursor = db.cursor()
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
......
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