Test whether access to the database is possible
Project description
Django-probes
Provides a Django management command to check whether the primary database is ready to accept connections.
Run this command in a Kubernetes or OpenShift Init Container to make your Django application wait until the database is available (e.g. to run database migrations).
Why Should I Use This App?
wait_for_database is a single command for all database engines Django supports. It automatically checks the database you have configured in your Django project settings. No need to code a specific wait command for Postgres, MariaDB, Oracle, etc., no need to pull a database engine specific container just for running the database readiness check.
Installation
The easiest way to install django-probes is with pip
$ pip install django-probes
Basic Usage
Add django-probes to your Django application:
INSTALLED_APPS = [
...
'django_probes',
]
2. Add an Init Container to your Kubernetes/OpenShift deployment configuration, which calls the wait_for_database management command:
- kind: Deployment
apiVersion: apps/v1
spec:
template:
spec:
initContainers:
- name: check-db-ready
image: my-django-app:latest
envFrom:
- secretRef:
name: django
command: ['python', 'manage.py', 'wait_for_database']
Command Line Options
The management command comes with sane defaults, which you can override if needed:
- –timeout, -t:
how long to wait (seconds), default: 180
- –stable, -s:
how long to observe whether connection is stable (seconds), default: 5
- –wait-when-down, -d:
delay between checks when database is down (seconds), default: 2
- –wait-when-alive, -a:
delay between checks when database is up (seconds), default: 1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_probes-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d77d9255fecb51ea4c02f2f7848d1aeaa608cab90a1a6dac13b8f307998b4ee9 |
|
MD5 | 062bea251cdc1ab11f7e9fc5466ed5c3 |
|
BLAKE2b-256 | 83c23ccacb2321a21216b191d108d827fe5394bbf426da783432c152c44e9a51 |