~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/core/management/commands/sqlreset.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from optparse import make_option
 
2
 
1
3
from django.core.management.base import AppCommand
 
4
from django.core.management.sql import sql_reset
 
5
from django.db import connections, DEFAULT_DB_ALIAS
2
6
 
3
7
class Command(AppCommand):
4
8
    help = "Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given app name(s)."
5
9
 
 
10
    option_list = AppCommand.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
 
6
17
    output_transaction = True
7
18
 
8
19
    def handle_app(self, app, **options):
9
 
        from django.core.management.sql import sql_reset
10
 
        return u'\n'.join(sql_reset(app, self.style)).encode('utf-8')
 
20
        return u'\n'.join(sql_reset(app, self.style, connections[options.get('database', DEFAULT_DB_ALIAS)])).encode('utf-8')