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

You can install the package via pip or uv:

Using uv (recommended)

uv add django-greenplum-updated
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.2.tar.gz (21.6 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.2-py3-none-any.whl (25.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_greenplum_updated-0.1.2.tar.gz
  • Upload date:
  • Size: 21.6 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.2.tar.gz
Algorithm Hash digest
SHA256 18bcf42e09d4332c0235ae7c085cda7598f113b798f4ee59f90d96fccae23891
MD5 c8aef7cfa3608366505bc07df721f7c5
BLAKE2b-256 7ca1824ee2431d9bf78663ec68c6668760c0aefed1bc174f7428765f396f6e49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_greenplum_updated-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aea8c9719624ff6b5a9c94563ec0656d70d753fc0750b692e9d89d6374cc9c4f
MD5 cd7f5571b03a5503a36e3f5f275d69fd
BLAKE2b-256 765777787c69ef3884c276bf53c2bea32babe57cc357d28497f01de692300a1b

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