diff --git a/instock/web/dataIndicatorsHandler.py b/instock/web/dataIndicatorsHandler.py index aeedd486e..b6718fa3b 100644 --- a/instock/web/dataIndicatorsHandler.py +++ b/instock/web/dataIndicatorsHandler.py @@ -51,13 +51,16 @@ def get(self): try: table_name = tbs.TABLE_CN_STOCK_ATTENTION['name'] if otype == '1': - sql = f"DELETE FROM `{table_name}` WHERE `code` = '{code}'" + # sql = f"DELETE FROM `{table_name}` WHERE `code` = '{code}'" + sql = f"DELETE FROM `{table_name}` WHERE `code` = %s" + self.db.query(sql,code) else: - sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE('{datetime.datetime.now()}','{code}')" - self.db.query(sql) + # sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE('{datetime.datetime.now()}','{code}')" + sql = f"INSERT INTO `{table_name}`(`datetime`, `code`) VALUE(%s, %s)" + self.db.query(sql,datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"),code) except Exception as e: err = {"error": str(e)} - logging.info(err) - self.write(err) - return + # logging.info(err) + # self.write(err) + # return self.write("{\"data\":[{}]}") \ No newline at end of file diff --git a/instock/web/dataTableHandler.py b/instock/web/dataTableHandler.py index 3336ae971..4b485dbcd 100644 --- a/instock/web/dataTableHandler.py +++ b/instock/web/dataTableHandler.py @@ -50,10 +50,12 @@ def get(self): date = self.get_argument("date", default=None, strip=False) web_module_data = sswmd.stock_web_module_data().get_data(name) self.set_header('Content-Type', 'application/json;charset=UTF-8') + if date is None: where = "" else: - where = f" WHERE `date` = '{date}'" + # where = f" WHERE `date` = '{date}'" + where = f" WHERE `date` = %s" order_by = "" if web_module_data.order_by is not None: @@ -64,6 +66,6 @@ def get(self): order_columns = f",{web_module_data.order_columns}" sql = f" SELECT *{order_columns} FROM `{web_module_data.table_name}`{where}{order_by}" + data = self.db.query(sql,date) - data = self.db.query(sql) self.write(json.dumps(data, cls=MyEncoder)) diff --git a/instock/web/templates/index.html b/instock/web/templates/index.html index 158c5a459..2ae544f10 100644 --- a/instock/web/templates/index.html +++ b/instock/web/templates/index.html @@ -164,7 +164,7 @@