0
我想弄清楚如何使用高級Python Scheduler保存一些作業後查看sqlite數據庫的模式。我需要它,因爲我想在UI中顯示這個工作。我試着寫一個簡單的腳本,節省作業:APScheduler如何保存數據庫中的作業? (Python)
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.沒有數據我究竟做錯了什麼?