Faster way to create your models in Django
Project description
Django Bulk Copy
Create your mass data in a faster way with the COPY
command.
Currently it supports only the Postgresql database.
Install
pip install django-bulk-copy
Usage
class TestModel(models.Model):
integer_field = models.IntegerField(null=True)
char_field = models.CharField(max_length=32, null=True)
boolean_field = models.BooleanField(default=False)
datetime_field = models.DateTimeField(null=True)
json_field = models.JSONField(null=True)
from bulk_copy import BulkCopy
objects = [
TestModel(
integer_field=i,
char_field=str(i),
boolean_field=bool(i % 2),
datetime_field=timezone.now(),
json_field={i: f"{i:>09}"},
)
for i in range(1000)
]
BulkCopy(objects)
BulkCopy only uses the initial time of the transaction if your model has a date/datetime field with auto_now=True
.
Additional
If you need to create your models from a csv file, django-postgres-copy could be a better alternative.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-bulk-copy-0.1.1.tar.gz
(4.0 kB
view hashes)
Built Distribution
Close
Hashes for django_bulk_copy-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b8fa1176db943908fde47fb57caa846359a236a0ca75988e051e0f61118f5b4 |
|
MD5 | 4238d790596922f85534291cdea99a60 |
|
BLAKE2b-256 | 1996744ba852b6179119228b1eb1064ca54afaa24d1cde20a0f6dd970823adca |