This script exports data from a Django model and saves it to a CSV file. It is designed to be used as a backup mechanism for your Django project.
We all know that Render provides free database service for 3 months. But, in free tier plan, the database will be deleted after 3 months and also we cannot take backup.
So, for taking backup of the data, you can make use of this script. The data will be stored in CSV format. Follow the instructions below and get your backup now!
- Python 3.x
- Django
- Clone the repository:
- Install the required dependencies:
git clone https://github.com/ravin-d-27/Render_Database_Backup_Script_For_Django.git
pip install -r requirements.txt
- Open the
Backup_Script.py
file. - Modify the following variables to match your project:
Your Project Name.settings
: Replace with the actual path to your Django project's settings module.yourapp
: Replace with the actual app name from your Django project.yourModel
: Replace with the actual model name from your Django projectfieldnames
: Replace with the actual field names from your Django model.- Save the script where manage.py file is located.
- Run the script:
python backup_script.py
This will export data from the specified Django model to a CSV file.
DJANGO_SETTINGS_MODULE
: Set the Django settings module path.fieldnames
: Specify the field names to be exported to the CSV file.backup_file_path
: Define the path for the CSV backup file.
Feel free to contribute by opening issues or submitting pull requests.
This project is licensed under the GNU GENERAL PUBLIC License - see the LICENSE file for details.