Skip to main content

Chunk large QuerySets into small chunks, and iterate over them without killing your RAM.

Project description

Chunk large QuerySets into small chunks, and iterate over them without killing your RAM.

https://travis-ci.org/novafloss/django-chunkator.svg

Usage

from chunkator import chunkator
for item in chunkator(LargeModel.objects.all(), 200):
    do_something(item)

This tool is intended to work on Django querysets.

Your model must define a pk field (this is done by default, but sometimes it can be overridden) and this pk has to be unique. django- chunkator has been tested with PostgreSQL and SQLite, using regular PKs and UUIDs as primary keys.

You can also use values():

from chunkator import chunkator
for item in chunkator(LargeModel.objects.values('pk', 'name'), 200):
    do_something(item)

If you want to manipulate the pages directly, you can use chunkator_page:

from chunkator import chunkator_page
queryset = LargeModel.objects.all().values('pk')
for page in chunkator_page(queryset, 200):
    launch_some_task([item['pk'] for item in page])

License

MIT License.

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-chunkator-1.2.0.tar.gz (3.6 kB view details)

Uploaded Source

Built Distributions

django_chunkator-1.2.0-py2-none-any.whl (5.0 kB view details)

Uploaded Python 2

django-chunkator-1.2.0.linux-x86_64.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file django-chunkator-1.2.0.tar.gz.

File metadata

File hashes

Hashes for django-chunkator-1.2.0.tar.gz
Algorithm Hash digest
SHA256 09a026ede35fa48bcef0f916add40be57e2753229ac4cecb5c7a3aed68e9944e
MD5 3c7d2c9fad637073d276df808fc22d32
BLAKE2b-256 323adc39d857ef3d6221d51d986ee9fc087fadd1a9a5a13141a63393dcb909f8

See more details on using hashes here.

File details

Details for the file django_chunkator-1.2.0-py2-none-any.whl.

File metadata

File hashes

Hashes for django_chunkator-1.2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 353601d6bb153df242386f3358d01e5fff2b67a9a82020516b7a7ae77ccfa497
MD5 17ab1b4d43a20495ce2b3e84cb9baf0b
BLAKE2b-256 77e7def685ca777eadc5732859b33f279dc009eaf753e43a0d24ea5f84707ac8

See more details on using hashes here.

File details

Details for the file django-chunkator-1.2.0.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for django-chunkator-1.2.0.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 456a0cd3d09b9606150248becd8ecab0eb21291fdbcb9dd26ff956473c3db5dc
MD5 627b03fc2e76ba61c0018becead68783
BLAKE2b-256 e7e2a2f98e53896a87cca07ee8a5c9d36907c8885022a04c5a4bd95129734e93

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page