Skip to main content

Hook db connection when you're running a long term sleep crawler assignment.

Project description

Flask Database Pacemaker

python_requires>=3.6 Flask>=1.0.2 Flask-APScheduler>=1.11.0 Flask-SQLAlchemy>=2.3.2

- How to use

  1. Set confing.py

DB_PACEMAKER_SWITCH is required MODELS_PATH_LIST is required POKE_DB_INTERVAL default value has _has been set as one 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
  1. Import package at app.py
from flask_dbpacemaker import DBPacemaker
  • Append this after you declared config and app
DBPacemaker.run(app, db=db, config=config)
  • If you got a exist scheduler, you have to add it like this.
DBPacemaker.run(app, db=db, config=config, display=True, secheduler=secheduler)

Note: The job permanent trigger is 'interval'.

Buy Me A Coffee Cheers! 🎉

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Flask-DBPacemaker-1.2.0.tar.gz (4.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page