/django/core/management/commands/sqlclear.py

https://code.google.com/p/mango-py/ · Python · 19 lines · 14 code · 5 blank · 0 comment · 0 complexity · 0ac2039003b57d8ca79a7df98bf03e52 MD5 · raw file

  1. from optparse import make_option
  2. from django.core.management.base import AppCommand
  3. from django.core.management.sql import sql_delete
  4. from django.db import connections, DEFAULT_DB_ALIAS
  5. class Command(AppCommand):
  6. help = "Prints the DROP TABLE SQL statements for the given app name(s)."
  7. option_list = AppCommand.option_list + (
  8. make_option('--database', action='store', dest='database',
  9. default=DEFAULT_DB_ALIAS, help='Nominates a database to print the '
  10. 'SQL for. Defaults to the "default" database.'),
  11. )
  12. output_transaction = True
  13. def handle_app(self, app, **options):
  14. return u'\n'.join(sql_delete(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')