Skip to main content

Django partitioning

Django partitioning is a package for Django, which implement PostgreSQL table partitioning on the fly, at the database level. It creates several triggers and functions and inserts them directly into the database. After setup partitioning, record will be inserted into the correct partition, if partition doesn't exist, it will be created for you automatically.

Requirements

  • Django >=1.11 <=5.0
  • PostgreSQL >= 8.0

Also, note psycopg2-binary (2.7.5-2.9.9) will be needed as PostgreSQL database adapter.

Installation

Install using pip...

$ pip install django-postgresql-partitioning

Configuration

  • Add partitioning to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    partitioning,
]
  • Add partitioning configuration to your models:
from partitioning.decorators import partitioning


@partitioning([
    {'type': 'list', 'column': 'tag'},
    {'type': 'range_month', 'column': 'created'},
])
class Message(models.Model):
    text = models.TextField()
    tag = models.CharField(max_length=255)
    created = models.DateTimeField()

  • Lastly setup partitioning:
$ python manage.py setup_partitioning app_name

Available settings

type - partition type, currently supported:

  • list
  • range_day
  • range_week
  • range_month
  • range_year

column - column, used to determine which partition record belongs to.

Testing

Clone the repo:

$ git clone https://github.com/starnavi-team/django-postgresql-partitioning.git

Install requirements.

$ pip install -r requirements.txt

Use tox testing tool to run the tests against all supported versions of Python and Django. Install tox globally, and then simply run:

$ tox

Metadata

Release files for django-postgresql-partitioning 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-postgresql-partitioning 0.1.1
File Size Uploaded
django-postgresql-partitioning-0.1.1.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-postgresql-partitioning 0.1.1
File Interpreter ABI Platform
django_postgresql_partitioning-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / django-postgresql-partitioning-0.1.1.tar.gz

Download URL django-postgresql-partitioning-0.1.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5635a0698f1b5b414193cfc69fa92462ffe84754a3423374cafdb6cc681fcff7
BLAKE2b-256 checksum
How to use checksums
addd34463b6c9329c682f8eeb249413127942e3173caf37ed41823d934f33147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release files / django_postgresql_partitioning-0.1.1-py3-none-any.whl

Download URL django_postgresql_partitioning-0.1.1-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
848ab84466505c9ff35daa65d0bbd078c05916100778c22dc92e7945ddcbb23d
BLAKE2b-256 checksum
How to use checksums
d213e6f0d535178121542eefe98d95c6bdf07e664170648fd1a3fb338d3e9f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page