我试图弄清楚在使用Advanced Python Scheduler保存一些作业后如何查看sqlite数据库的模式。我需要它,因为我想在UI中显示作业。我试着编写一个节省工作的简单脚本:
from pytz import utc
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
from datetime import datetime
import os
from apscheduler.schedulers.blocking import BlockingScheduler
jobstores = {
'default': SQLAlchemyJobStore(url='sqlite:///test.db')
}
executors = {
'default': ThreadPoolExecutor(20),
'processpool': ProcessPoolExecutor(5)
}
job_defaults = {
'coalesce': False,
'max_instances': 3
}
scheduler = BackgroundScheduler(jobstores=jobstores, executors=executors, job_defaults=job_defaults, timezone=utc)
def tick():
print('Tick! The time is: %s' % datetime.now())
scheduler = BlockingScheduler()
scheduler.add_executor('processpool')
scheduler.add_job(tick, 'interval', seconds=3)
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
但是终端中的命令“.fullschema”告诉我,test.db中没有表,也没有数据。我究竟做错了什么?
答案 0 :(得分:1)
您正在创建两个调度程序,但只启动具有默认配置的调度程序。