Flask Database Pacemaker
python_requires>=3.6
Flask>=1.0.2
Flask-APScheduler>=1.11.0
Flask-SQLAlchemy>=2.3.2
- Log
| # | date | version |
|---|---|---|
| 1 | 2020/12/03 | v1.2.3 |
| 2 | 2020/12/03 | v1.2.4 |
| 3 | 2020/12/05 | v1.2.5 |
| 4 | 2020/12/07 | v1.2.7 |
v1.2.3
- Fixed
AttributeError: 'NoneType' object has no attribute 'items'issue due to mysql connection has been terminated.
v1.2.4
- 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_LISThas not been set properly.
v1.2.5
- Replace new line of the error raise from sqlalchemy.
- Change datetime format method.
- Make the code efficient.
v1.2.7
- Add validation, testing awake() before assign the job to APScheduler.
- How to use
1. Add setting into config.py
DB_PACEMAKER_SWITCHis requiredMODELS_PATH_LISTis requiredPOKE_DB_INTERVALdefault: 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
2. Establish in app.py
Note: Append this after you declared
configandapp
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! 🎉
Metadata
Release files for Flask-DBPacemaker 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Flask-DBPacemaker-1.3.2.tar.gz | 5.5 kB | Without provenance | Details for Flask-DBPacemaker-1.3.2.tar.gz |
Release files / Flask-DBPacemaker-1.3.2.tar.gz
| Download URL | Flask-DBPacemaker-1.3.2.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8bb33a971b5a175641bf88e717e6b17ce85d2bd2fe3618b6b3f1ab52ebfb2513
|
|
BLAKE2b-256 checksum How to use checksums |
a7df3dadd6bed4ac4818f4c75c987423fbd404446cca612f783f14b68780b63c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for Flask-DBPacemaker 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.