views:

78

answers:

2

How can I drop all tables from database using mannage.py and command line? Is there any way to do that executing manage.py with appropriate parameters so that to execute it from .NET application?

+1  A: 

AFAIK there is no management command to drop all tables. If you don't mind hacking 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).

Manoj Govindan
sqlclear "prints the drop statements" but how to execute them in single command line call
mack369
Pipe it to `./manage.py dbshell`.
Mike DeSimone
+1  A: 

If you're using the South package to handle database migrations (highly recommended), then you could just use the ./manage.py migrate appname zero command.

Otherwise, I'd recommend the ./manage.py dbshell command, piping in SQL commands on standard input.

Mike DeSimone