from apscheduler.schedulers.background import BlockingScheduler
logging.basicConfig(level=logging.INFO)
url = "http://{}:{}/data/export".format(LOCAL_HOST, LOCAL_PORT)
if __name__ == '__main__':
scheduler = BlockingScheduler(timezone="Asia/Shanghai")
scheduler.add_job(loop_export_task, 'cron', day_of_week='*', hour='1', minute='0', second='0')
logging.info('The Next Run Time is: ', scheduler.get_jobs()[0].next_run_time)
@bp.route('/data/export')
select macaddr, recordtime, eventdetail, eventtype, ipaddr, pkttime, CONCAT(packet,'') as packet,
starttime, count_num, action, hashid as hash_id, endtime
from events_ipmac where date(recordtime)=date_sub(curdate(),interval 1 day);
timestamp = int(time.time())
_, result = pool_connect_db.select_all(sql)
filepath = os.path.join(BASE_PATH, 'ipmac_sql')
if not os.path.exists(filepath):
with open('%s/data.json' % filepath, 'wb') as _file:
return jsonify({'code': 200, 'msg': 'export data success'})