summaryrefslogtreecommitdiff
path: root/script/schedule.py
diff options
context:
space:
mode:
Diffstat (limited to 'script/schedule.py')
-rw-r--r--script/schedule.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/script/schedule.py b/script/schedule.py
index 37c94ff..54b67c5 100644
--- a/script/schedule.py
+++ b/script/schedule.py
@@ -1,10 +1,12 @@
import datetime
+import json
import threading
import time
import pymysql
from neomodel import config, db
from neomodel.integration.pandas import to_dataframe
+from pymysql.converters import escape_string
from schedule import repeat, every, run_pending, run_all, idle_seconds
from apps.model import NodeResolver53
@@ -70,8 +72,12 @@ def refresh_neo4j():
# 双栈计数
dual_countresult = db.cypher_query(dualcountcypher, retry_on_session_expire=True)[0][0]
- sql = "REPLACE INTO %s(id,name,data) VALUES (1,'%s','{\"%s\":\"%s\"}')" % (
- da.tabname, "dualcount", "count", str(dual_countresult[0]))
+ # 将结果包装为json字符串
+ param = {'count': dual_countresult[0]}
+ d_param = json.dumps(param)
+
+ sql = "REPLACE INTO %s(id,name,data) VALUES (1,'%s','%s')" % (
+ da.tabname, "dualcount", escape_string(d_param))
try:
da.cursor.execute(sql)
da.conn.commit()
@@ -82,7 +88,7 @@ def refresh_neo4j():
# 双栈信息
dual_dataresult = to_dataframe(db.cypher_query(dualdatacypher, retry_on_session_expire=True))
res = dual_dataresult.to_json(orient="index")
- sql = "REPLACE INTO %s(id,name,data) VALUES (2,'%s','%s')" % (da.tabname, "dualdata", res)
+ sql = "REPLACE INTO %s(id,name,data) VALUES (2,'%s','%s')" % (da.tabname, "dualdata", escape_string(res))
try:
da.cursor.execute(sql)
da.conn.commit()