Re: Search & replace an object in the database

2022-01-24 Thread jools
Thanks! I’ll consider this. The whole thing is supposed to be a tool for everyday work (although: a very dangerous one!), so the “fix the database once” strategy isn’t going to work for me. I’ve added some tests for checking different relation types (m2m, fk, one-to-one, generic relation, pare

Re: Search & replace an object in the database

2022-01-21 Thread Thomas Lockhart
Yes this exactly. A couple of possible additions: I’ve had great luck using python and SQL queries to manipulate a database including converting from other schemas and merging duplicate records. Make a test database from your backup, and beat it up with your scripted code until you are happy wi

Re: Search & replace an object in the database

2022-01-21 Thread Bernard Mallala
I would approach this differently and from the database side mostly 1. Backup the database so you can restore if something happens 2. In Django, Create an an empty copy of the Customer database e.g CustomerB 3. Using a SQL query tool, select all duplicate copies from Customer and

Re: Search & replace an object in the database

2022-01-21 Thread Yeboah Dominic
Okay bro try this script hope it works On Fri, 21 Jan 2022 at 10:05, jools wrote: > Dear Django users, > > here’s an interesting case and I’m curious whether somebody can point me > in the right direction. > > Here’s the problem: > My company has a database of customers. Over the years, many dup

Re: Search & replace an object in the database

2022-01-21 Thread jools
Here’s an update: I sticked to the idea of using collector; it categorizes models from a deletion perspective into: - fast_deletes - models that can be easily deleted, without checking for other relations - update_fields - field that have SET_NULL, i.e. relations to the customer ob

Search & replace an object in the database

2022-01-21 Thread jools
Dear Django users, here’s an interesting case and I’m curious whether somebody can point me in the right direction. Here’s the problem: My company has a database of customers. Over the years, many duplicates have been created. For cleaning up duplicates, I’d like to have a search-and-replace f