Add PostgreSQL table partitioning to Django models
Project description
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
toINSTALLED_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
Project details
Release history Release notifications | RSS feed
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 django-postgresql-partitioning-0.1.1.tar.gz
.
File metadata
- Download URL: django-postgresql-partitioning-0.1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5635a0698f1b5b414193cfc69fa92462ffe84754a3423374cafdb6cc681fcff7 |
|
MD5 | 0d4fd3a81cc3504f7cc3c49ede09c1cb |
|
BLAKE2b-256 | addd34463b6c9329c682f8eeb249413127942e3173caf37ed41823d934f33147 |
File details
Details for the file django_postgresql_partitioning-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: django_postgresql_partitioning-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848ab84466505c9ff35daa65d0bbd078c05916100778c22dc92e7945ddcbb23d |
|
MD5 | 55d04ebffe04d2fee4c07464b45d5444 |
|
BLAKE2b-256 | d213e6f0d535178121542eefe98d95c6bdf07e664170648fd1a3fb338d3e9f0d |