web/lib/django/core/management/commands/sqlflush.py
changeset 38 77b6da96e6f1
equal deleted inserted replaced
37:8d941af65caf 38:77b6da96e6f1
       
     1 from optparse import make_option
       
     2 
       
     3 from django.core.management.base import NoArgsCommand
       
     4 from django.core.management.sql import sql_flush
       
     5 from django.db import connections, DEFAULT_DB_ALIAS
       
     6 
       
     7 class Command(NoArgsCommand):
       
     8     help = "Returns a list of the SQL statements required to return all tables in the database to the state they were in just after they were installed."
       
     9 
       
    10     option_list = NoArgsCommand.option_list + (
       
    11         make_option('--database', action='store', dest='database',
       
    12             default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '
       
    13                 'SQL for.  Defaults to the "default" database.'),
       
    14     )
       
    15 
       
    16     output_transaction = True
       
    17 
       
    18     def handle_noargs(self, **options):
       
    19         return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8')