Skip to content

disqus/nydus-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b652ea2 · Mar 26, 2013

History

6 Commits
Mar 26, 2013
May 22, 2012
Mar 26, 2013
May 22, 2012
May 18, 2012
May 18, 2012
Mar 26, 2013
May 22, 2012
Mar 26, 2013
Mar 26, 2013
Mar 26, 2013

Repository files navigation

nydus-django

Note

This package was formerly nydus.contrib.django, but is not backwards compatible.

Partitioned Models

Add a Nydus connection to your settings:

DATABASES = {
    'myshards': {
        'ENGINE': 'djnydus.db.backend',
        'OPTIONS': {
            'defaults': {
                'backend': 'django.db.backends.postgresql_psycopg2',
                'name': 'myshards',
            }
            'hosts': {
                0: {'host': '192.168.0.100'},
                1: {'host': '192.168.0.101'},
                2: {'host': '192.168.0.102'},
                3: {'host': '192.168.0.103'},
            },
        }
    },
}

Extend the PartitionModel class when creating your models:

from django.db import models
from djnydus.db.shards import PartitionModel, PartitionSequenceField

class MyModel(PartitionModel):
    user_id = models.PositiveIntegerField()

    class Shards:
        key = 'user_id'
        cluster = 'myshards'
        size = 1024

Query the nodes passing in your key:

objects = MyModel.objects.filter(user_id=1)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages