Skip to main content

Make Django wait until database is ready. Probes for Docker and Kubernetes.

Project description

Django-probes Latest version on PyPI

GitHub Workflow Status GitHub Workflow Status Python versions Software license

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.


The easiest way to install django-probes is with pip

$ pip install django-probes

Basic Usage

  1. Add django-probes to your Django application:

2. Add an Init Container to your Kubernetes/OpenShift deployment configuration, which calls the wait_for_database management command:

- kind: Deployment
  apiVersion: apps/v1
        - name: wait-for-database
          image: my-django-app:latest
          - secretRef:
              name: django
          command: ['python', '', 'wait_for_database']

Use with Your Own Command

Alternatively, you can integrate the wait_for_database command in your own management command, and do things like database migration, load initial data, etc. with roughly the same Kubernetes setup as above.

from import call_command

# ...

Command Line Options

The management command comes with sane defaults, which you can override if needed:

–timeout, -t:how long to wait for the database before timing out (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
–database:which database of settings.DATABASES to wait for, default: default

Project details

Download files

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

Files for django-probes, version 1.6.0
Filename, size File type Python version Upload date Hashes
Filename, size django_probes-1.6.0-py3-none-any.whl (5.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django_probes-1.6.0.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page