Skip to content

Cute little model manager for batching expensive Django update_or_create/get_or_create operations

Notifications You must be signed in to change notification settings

mattalytics/batched_models

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

batched_models

Not for production use. This is an initial commit

A cute little model manager for batching expensive Django update_or_create/get_or_create operations

Django's get_or_create/update_or_create functions are useful, but slow. This model manager provides a means to speed things up a bit.

Usage

create a model like this:

class bulker(models.Model):
    id=models.AutoField(primary_key=True)
    x=models.TextField(unique=True)
    y=models.TextField()

    objects = BulkManager()

Now, you can do this:

batch = bulker.objects.bulk_operation()
batch.update_or_create(x='199999', defaults={'y':2})
batch.update_or_create(x='19998', defaults={'y':1})
"""
Add thousands more operations here...
"""
batch.run()

About

Cute little model manager for batching expensive Django update_or_create/get_or_create operations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages