data_job/sql_job.py

45 lines
1.0 KiB
Python
Raw Permalink Normal View History

2025-03-04 10:24:36 +08:00
from utils.read_sql_files import read_sql_files
from apscheduler.schedulers.background import BlockingScheduler
from utils.log import Log
import logging
# 配置logging以控制日志输出
logger = logging.getLogger('apscheduler')
# 设置logger的级别为WARNING这样INFO级别的日志就不会被处理了
logger.setLevel(logging.WARNING)
def dim():
read_sql_files('dim')
def dwd():
read_sql_files('dwd_before')
read_sql_files('dwd_after')
def dws():
read_sql_files('dws_before')
read_sql_files('dws_after')
def ads():
read_sql_files('ads')
if __name__ == '__main__':
log = Log().getlog()
log.info(f"---------job开始执行:---------")
sch = BlockingScheduler(timezone='Asia/Shanghai')
# 每天4点执行dim
sch.add_job(dim, 'cron', hour=4, minute=0)
# 每天5点执行执行dwd
sch.add_job(dwd, 'cron', hour=5, minute=0)
# 每天6点十分执行dws
sch.add_job(dws, 'cron', hour=6, minute=10)
# 每天七点十分执行ads
sch.add_job(ads, 'cron', hour=7, minute=10)
sch.start()