This is a question about django DB renewal.

Asked 2 years ago, Updated 2 years ago, 47 views

Hello, I'm Jango and DB Wang novice. I'm writing to ask you a long db question.

I wrote a script to store the contents of a site information obtained through real-time crawling in Django db.

What I'm curious about is that if I run this script again, is there a way to save only the modified or added parts in the db without saving the duplicate values?

django database

2022-09-22 15:57

1 Answers

What you probably want is to call UpdateOrCreate.

obj, created = Person.objects.update_or_create(
    first_name='John', last_name='Lennon',
    defaults={'first_name': 'Bob'},
)


2022-09-22 15:57

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.