Skip to main content

A Django app to automatically handle sharding model tables in MySQL.

Project description

Django table sharding is an app that will allow you to shard your database tables in the same database using a shard key or shard suffix.

Detailed documentation is in the “docs” directory.

Quick start

  1. Add “django_table_sharding” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'django_table_sharding',
    ]

Every time migrations are run it will copy changes from the source table to the sharded tables.

Set the model manager to the models you want to shard into their own tables. Example:

objects = ShardManager()

The migration process will automatically find all sharded models and apply the new migrations.

Sharded models can have ForeignKeys, but other models cannot foreign key to the sharded models because original table is not used.

Sharded models cannot contain OneToOneField, or ManyToManyField, for same reason.

When running migrations the normal migration will run as normal, and then changes to source table, will be applied to all shards in the database.

Before deploying to production please make sure everything fits your needs.

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-table-sharding-1.0.3.tar.gz (15.3 kB view details)

Uploaded Source

File details

Details for the file django-table-sharding-1.0.3.tar.gz.

File metadata

  • Download URL: django-table-sharding-1.0.3.tar.gz
  • Upload date:
  • Size: 15.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for django-table-sharding-1.0.3.tar.gz
Algorithm Hash digest
SHA256 2e2fa63ed23364b01b81d0d92cfcafa1e91d43af684441234766f0c597166c8c
MD5 a3b6bafc733e72a212a33000c0071d19
BLAKE2b-256 bce2b964180ed1745c40f60e93abbffd1b6463585a1dff2f5c33c2f887173c1b

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