How to drop all tables from the database with manage py CLI in Django

0 votes
How can I drop all tables from a database using manage.py and command line? Is there any way to do that executing manage.py with appropriate parameters so I can execute it from a .NET application?
Aug 7, 2020 in Python by kartik
• 37,530 points
3,312 views

1 answer to this question.

0 votes

Hello @kartik,

Python you can write your own custom command to do that. You may find the sqlclear option interesting. Documentation says that ./manage.py sqlclear Prints the DROP TABLE SQL statements for the given app name(s).

use:

./manage.py sqlclear | ./manage.py dbshell

Hope this helps!!

Thank You!!

answered Aug 7, 2020 by Niroj
• 82,820 points

Related Questions In Python

0 votes
1 answer

I want to download a file from the website by web scraping. Can anyone explain how to do this in jupyter lab (python) with an example?

Hey, Web scraping is a technique to automatically ...READ MORE

answered Apr 7, 2020 in Python by Gitika
• 65,950 points
878 views
0 votes
1 answer

How to set the encoding for the tables' char columns in django?

Hello @kartik, Django does not specify charset and ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,820 points
599 views
0 votes
1 answer

How to order_by a JSON from serializers.py file in django rest framework?

Hello @kartik, There's an easy way, just override ...READ MORE

answered Jul 2, 2020 in Python by Niroj
• 82,820 points
1,661 views
0 votes
1 answer
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
970 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,820 points
433 views
0 votes
1 answer

How to clear a database from the CLI with manage.py in Django?

Hello @kartik, To drop the database and run syncdb again. ...READ MORE

answered Aug 7, 2020 in Python by Niroj
• 82,820 points
889 views
0 votes
1 answer

How to output text from database with line breaks in a django template?

Hello @kartik, Use linebreaks or linebreaksbr filter: {{ text|linebreaks }} Or surround the text ...READ MORE

answered Jun 24, 2020 in Python by Niroj
• 82,820 points
4,487 views