Comments (9)
I think it's possible to add this feature. I would call it bulk_update_or_create
because django already has a update_or_create
for single instances.
But even if we implement this function here, we will also need to know which instances already exist (performing an additional query). bulk_update_or_create
will actually split the list of instances and call bulk_create
and bulk_update
separately. So each batch will perform 3 queries.
Seems reasonable for you? Any better approach?
from django-bulk-update.
Hi,
I'm not sure it is a good idea to include bulk_create into this project. Django already has built-in bulk_create method. Why not separate the objects into create and update, then use bulk_create and bulk_update explicitly?
from django-bulk-update.
@candeira I'm way into that! I could use this on my project, for sure.
@aykut bulk_update_or_create
is different from bulk_create
?
from django-bulk-update.
@candeira @aykut @ckcollab this would be amazingly helpful
from django-bulk-update.
@aykut the problem with doing bulk_create is that you need to know in advance which ones exist already - so requires an additional query i think
from django-bulk-update.
I need this feature. Any news?
from django-bulk-update.
It's seems reasonable. Although both postgres and mysql now suport bulk upsert:
https://stackoverflow.com/questions/34514457/bulk-insert-update-if-on-conflict-bulk-upsert-on-postgres
https://stackoverflow.com/questions/6286452/mysql-bulk-insert-or-update
from django-bulk-update.
I do agree with @arnau126, Any update about this feature.
from django-bulk-update.
The 3 query approach is a race condition; unless you can be sure your program is the only one writing to that table you'll have to add retry logic around the transaction (as records can get added and removed between your read and create step).
SQL level UPSERT is the way to go for atomic single query update/create.
from django-bulk-update.
Related Issues (20)
- Use pythonic sequence ducktyping instead of hardcoding to list type
- tests/models.py breaks everything. HOT 1
- bulk_update doesn't work if the pk of the table is an UUID
- BulkUpdateManager' object has no attribute 'normalize_email' HOT 2
- Bulk Update Progress Logs HOT 1
- TypeError if updating ArrayField
- bulk_create
- Unnecessary variable loaded_fields HOT 13
- [Microsoft][ODBC Driver 13 for SQL Server]COUNT field incorrect or syntax error (0) (SQLExecDirectW)')
- Let travis use different databases HOT 1
- Raise error when model with empty pk field is passed HOT 3
- Many to many field HOT 2
- BulkUpdateQuerySet object is not an iterator
- Document that bulk update is available in Django 2.2 HOT 11
- Error "ORA-00942: table or view does not exist" in Oracle DB
- 'Manager' object has no attribute 'bulk_update'
- Invalid utf8mb4 character string
- add suport for JsonField
- Djngo REST API: KeyError at /api/update
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-bulk-update.