Skip to content

disqus/nydus-django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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