Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Create and start MySQL/PostgreSQL containers with a single management command

Project Description

Create and start MySQL/PostgreSQL containers with a single management command.

  • If an image isn’t available, it will be pulled.
  • If a container with the specified configuration doesn’t exist, it will be created.
  • If a container is not running, it will be started.

Necessary settings are taken from settings.py.

  • SQLite databases are ignored.
  • For MySQL and PostgreSQL, one container is created per database.

Also, Docker settings are picked up from standard DOCKER_* environment variables.

Usage

./manage.py db_quick_setup

'db_quick_setup' should be added to INSTALLED_APPS:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'db_quick_setup'
)

'HOST' in database settings should point to Docker hostname/IP. You can use find_docker_host() to auto-detect it.

from db_quick_setup import find_docker_host

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'mysql_db',
        'USER': 'mysql_db',
        'PASSWORD': 'mysql_db_pass',
        'HOST': find_docker_host(),
        'PORT': 53308
    }
}

'NAME', 'USER', 'PASSWORD' and 'PORT' can have arbitrary values, the container will be configured accordingly.

  • For MySQL 'NAME' and 'USER' should have the same value, it’s a limitation of the official image.

Settings

DOCKER_MYSQL_IMAGE: Docker image to use for MySQL databases. Default is the official image - mysql:latest.

DOCKER_POSTGRES_IMAGE: Docker image for PostgreSQL databases. Default is the official image - postgresql:latest.

DOCKER_ASSERT_HOSTNAME: enable SSL hostname validation (boolean). True by default.

DOCKER_PRIVILEGED: create privileged containers. Currently used as a workaround for permission problems on Travis CI. It is disabled by default, and shouldn’t be enabled usually.

Release History

This version
History Node

0.0.2

Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
django-db-quick-setup-0.0.2.tar.gz
(8.4 kB) Copy SHA256 Hash SHA256
Source None Sep 20, 2015

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting