equal
deleted
inserted
replaced
|
1 from optparse import make_option |
|
2 |
1 from django.core.management.base import NoArgsCommand |
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 |
2 |
6 |
3 class Command(NoArgsCommand): |
7 class Command(NoArgsCommand): |
4 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." |
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." |
5 |
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 |
6 output_transaction = True |
16 output_transaction = True |
7 |
17 |
8 def handle_noargs(self, **options): |
18 def handle_noargs(self, **options): |
9 from django.core.management.sql import sql_flush |
19 return u'\n'.join(sql_flush(self.style, connections[options.get('database', DEFAULT_DB_ALIAS)], only_django=True)).encode('utf-8') |
10 return u'\n'.join(sql_flush(self.style, only_django=True)).encode('utf-8') |
|