Skip to main content

Library contains django commands which helps to prepare and manage PostgreSQL database.

Project description

Django-psycopg2-extension

Library contains django commands which helps to prepare and manage PostgreSQL database.

Quickstart

Install djjango-psycopg2-extension

pip install django-psycopg2-extension

Add psycopg2_extension to your INSTALLED_APPS:

INSTALLED_APPS = [
    # Django apps...
    'psycopg2_extension',
]

Commands

psqlinit

Django command psqlinit create a database defined in django settings.

You can define specific database settings with standard django DATABASE settings:

DATABASES = {
    'default': {
        ...
        'EXTENSIONS': ['postgis', 'unaccent'],  # extensions to be installed with psqlinit command
        'SNAPSHOT_FILE': Path('data', 'sql', 'local', 'init_default.sql'), # SQL which will be loaded after database initialization
    },
}

Snapshot and extensions are automatically loaded when database is preparing for tests too.

psqlclean

PostgreSQL database requires often call VACUUM and REINDEX. The command psqlclean performs these operations.

You can define specific database settings for psqlclean command with standard django DATABASE settings:

DATABASES = {
    'default': {
        ...
        'VACUUM': {
            'EXCLUDE': ['users_user'],  # list of excluded tables
            'TABLES': ['users_permission'],  # list of tables to vacuum, all tables are selected if the setting is not set
            'TABLES_FULL': ['users_permission'],  # list of tables to vacuum full
            'TABLES_REINDEX': ['users_permission'],  # list of tables to reindex
        }
    },
}

psqlsnapshot

Command which creates SQL dump with pg_dump script and store it to the database 'SNAPSHOT_FILE' setting.

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

Built Distribution

File details

Details for the file skip-django-psycopg2-extension-0.1.1.1.tar.gz.

File metadata

File hashes

Hashes for skip-django-psycopg2-extension-0.1.1.1.tar.gz
Algorithm Hash digest
SHA256 5223b17d61700b9dc472da359d50ab25db1ef800d0bebb82ff78331b008eddee
MD5 152234d8877d03432bdcd149660ac4c8
BLAKE2b-256 2ec4a3fe940805071a4fcab97d42abf3b3a8c23956957e91cd94bfcf2a9a102f

See more details on using hashes here.

File details

Details for the file skip_django_psycopg2_extension-0.1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for skip_django_psycopg2_extension-0.1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f04d8aa41cf5c63584e696a319d52ab1588516b53125ae7075ed4f9ec7e30d0e
MD5 22f52212b72ff3da7fced315a85011d2
BLAKE2b-256 df7967ac123136f098fe9e0973db353529e3867b3db25d0aa9ba18338acc2cdf

See more details on using hashes here.

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