0

How can I delete the entire contents of my database? Currently I have a script that reads a CSV file and stores the content in my database. But it's important to delete everything in the database before I add the new data.

-> I run the script -> Database contents are deleted -> new data will be saved

I have to do it that way, because the CSV file changes 1-2 times a day and the information it contains is completely different.

  • Possible duplicate of [How to remove all of the data in a table using Django](https://stackoverflow.com/questions/4532681/how-to-remove-all-of-the-data-in-a-table-using-django) – General4077 Aug 07 '19 at 11:54

1 Answers1

0

Take a look at this answer if seems that you can use the syntax:

<model>.objects.all().delete() # for a specific table

or

python manage.py flush # to clear the values from the entire database

also for future reference a minimum reproducible example is helpful to those trying to provide you a quality answer. In this case you say database. I assume you mean a specific table because you are reading a single csv, but with a small code example my interpretation may have been different.

General4077
  • 435
  • 1
  • 8
  • 17