tzlocal==2.1
python_requires>=3.6
Flask>=1.0.2
Flask-APScheduler>=1.11.0
Flask-SQLAlchemy>=2.3.2
# | date | version |
---|---|---|
5 | 2020/12/07 | v1.3.2 |
4 | 2020/12/07 | v1.2.7 |
3 | 2020/12/05 | v1.2.5 |
2 | 2020/12/03 | v1.2.4 |
1 | 2020/12/03 | v1.2.3 |
- Fixed
pytz
normalize
andzone
deprecation warning.
- Fixed
AttributeError: 'NoneType' object has no attribute 'items'
issue due to mysql connection has been terminated.
- Handle
sqlalchemy.exc.ProgrammingError
, the problem cause by some specific ORM models not exist in current database. - Handle database not found issue.
- Raise error if
MODELS_PATH_LIST
has not been set properly.
- Replace new line of the error raise from sqlalchemy.
- Change datetime format method.
- Make the code efficient.
- Add validation, testing awake() before assign the job to APScheduler.
DB_PACEMAKER_SWITCH
is requiredMODELS_PATH_LIST
is requiredPOKE_DB_INTERVAL
default: 1 hour.
# for DBPacemaker - 透過定時排程請求DB,保持連線
DB_PACEMAKER_SWITCH = True if os.environ['ENVIRONMENT'] == 'develop' else False
MODELS_PATH_LIST = ['spyder_common.models']
POKE_DB_INTERVAL = 60 * 60
Note: Append this after you declared
config
andapp
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_dbpacemaker import DBPacemaker # import package
from config import Config
app = Flask(__name__)
config = Config()
app.config.from_object(config)
db = SQLAlchemy(app)
DBPacemaker.run(app, db=db, config=config) # setup here
- If you've set a scheduler
DBPacemaker.run(app, db=db, config=config, secheduler=your_flask_apscheduler)
Note: The job permanent trigger is interval
.
If you like my work, please consider buying me a coffee or PayPal
Thanks for your support! Cheers! 🎉