You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sqlflush.py 795B

12345678910111213141516171819202122
  1. from django.core.management.base import BaseCommand
  2. from django.core.management.sql import sql_flush
  3. from django.db import DEFAULT_DB_ALIAS, connections
  4. class Command(BaseCommand):
  5. help = (
  6. "Returns a list of the SQL statements required to return all tables in "
  7. "the database to the state they were in just after they were installed."
  8. )
  9. output_transaction = True
  10. def add_arguments(self, parser):
  11. super().add_arguments(parser)
  12. parser.add_argument(
  13. '--database', default=DEFAULT_DB_ALIAS,
  14. help='Nominates a database to print the SQL for. Defaults to the "default" database.',
  15. )
  16. def handle(self, **options):
  17. return '\n'.join(sql_flush(self.style, connections[options['database']], only_django=True))