django-postgres-createdb

create postgres database


Keywords
django, postgres, create, cli, python
License
Unlicense
Install
pip install django-postgres-createdb==2020.12.3

Documentation

Installation

$ [sudo] pip install django-postgres-createdb

Examples

example 1 - management command:

settings.py

INSTALLED_APPS+=['django_postgres_createdb']

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('DB_NAME'),
        'USER': os.getenv('DB_USER'),
        'PASSWORD': os.getenv('DB_PASS'),
        'HOST': os.getenv('DB_HOST'),
        'PORT': os.getenv('DB_PORT'),
    }
}
$ python manage.py createdb
$ python manage.py createdb "default"

example 2 - python module cli:

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('DB_NAME'),
        'USER': os.getenv('DB_USER'),
        'PASSWORD': os.getenv('DB_PASS'),
        'HOST': os.getenv('DB_HOST'),
        'PORT': os.getenv('DB_PORT'),
    }
}
$ export DJANGO_SETTINGS_MODULE=settings
$ python -m django_postgres_createdb
$ python -m django_postgres_createdb "default"

Related

readme42.com