Skip to main content

No project description provided

Project description

Django-Greenplum

Django ORM backend for Greenplum — a massively parallel PostgreSQL-based database.

Originally authored by souno.


Requirements

  • Python 3.8+
  • Django >= 3.0
  • psycopg2 (or psycopg2-binary on Linux)

Installation

Copy the django-greenplum directory to your project root, then configure the database backend:

DATABASES = {
    'default': {
        'ENGINE'  : 'django-greenplum',
        'NAME'    : 'mydb',
        'USER'    : 'gpadmin',
        'PASSWORD': 'secret',
        'HOST'    : '127.0.0.1',
        'PORT'    : '5432',
    }
}

Partitioning

Greenplum supports table partitioning at the storage level. This backend lets you declare the partition strategy directly on your Django model as a class attribute.

Import the partition class and assign it to greenplum_partition:

from partition import RangePartition, ListPartition

Range partition — automatic (EVERY)

Splits the table into equal sub-partitions over a continuous range.

class Orders(models.Model):
    order_date = models.DateField()
    amount     = models.DecimalField(max_digits=12, decimal_places=2)

    greenplum_partition = RangePartition(
        column='order_date',
        start='2020-01-01',
        end='2026-01-01',
        every='1 month',   # string → INTERVAL '1 month'
                           # integer → plain numeric step
    )

Generated SQL suffix:

PARTITION BY RANGE ("order_date")
(START ('2020-01-01') INCLUSIVE END ('2026-01-01') EXCLUSIVE EVERY (INTERVAL '1 month'))

Range partition — manual named partitions

class Events(models.Model):
    event_date  = models.DateField()
    description = models.TextField()

    greenplum_partition = RangePartition(
        column='event_date',
        partitions=[
            ('p2023', '2023-01-01', '2024-01-01'),
            ('p2024', '2024-01-01', '2025-01-01'),
            ('p2025', '2025-01-01', '2026-01-01'),
        ],
    )

List partition

class Sales(models.Model):
    region  = models.CharField(max_length=20)
    revenue = models.DecimalField(max_digits=14, decimal_places=2)

    greenplum_partition = ListPartition(
        column='region',
        partitions=[
            ('north', ['north', 'northeast']),
            ('south', ['south', 'southeast']),
            ('other', ['west', 'east']),
        ],
    )

RangePartition parameters

Parameter Type Description
column str Model field name to partition by
start value Inclusive start bound (required with every)
end value Exclusive end bound (required with every)
every str or int Step for automatic partitions ("1 month", "1 year", 10, …)
partitions list of 3-tuples Manual named partitions (name, start, end)
start_inclusive bool (default True) Whether the start bound is INCLUSIVE
end_exclusive bool (default True) Whether the end bound is EXCLUSIVE

every and partitions are mutually exclusive.

ListPartition parameters

Parameter Type Description
column str Model field name to partition by
partitions list of 2-tuples (partition_name, [value, value, …]) for each partition

Notices

  1. The primary key is used as the distribution key by default. Greenplum does not support multiple unique keys on the same table — avoid defining unique=True on non-primary-key fields.

  2. Because of the above limitation, the default Django admin and auth applications may not work as expected.

  3. Partition child tables are automatically excluded from Django's model introspection — only the parent (root) table is visible.

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

django_greenplum_updated-0.1.1.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_greenplum_updated-0.1.1-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

Details for the file django_greenplum_updated-0.1.1.tar.gz.

File metadata

  • Download URL: django_greenplum_updated-0.1.1.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_greenplum_updated-0.1.1.tar.gz
Algorithm Hash digest
SHA256 93cd8c6f5cf93c168f1a1e295e2a1c73c865c413273dfed083189a5b492b0e0e
MD5 3b83b77cd74fd26bced818797e161b9c
BLAKE2b-256 98e6ec1e44f27c9217a70545c3593acd4acca422974304db9dfc0f7bc5fe21fb

See more details on using hashes here.

File details

Details for the file django_greenplum_updated-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: django_greenplum_updated-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 25.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_greenplum_updated-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b2a3f6ce89ee6cc61cf1647c4611c521257e11c384b98cd5a3cec7ccee49eb
MD5 d480381b6114dd1ffb4e35978c7252a3
BLAKE2b-256 f40fe69ecaa54e056663457af8e2db77c5957b6d985ec91239d1543117de4cd9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page