freshdb management command

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
"""
put in your project's management/commands/freshdb.py
"""

from django.core.management.base import BaseCommand

class Command(BaseCommand):
    help = "Drops and re-creates the database"

    def handle(self, *args, **options):
        from django.db import connection
        from django.conf import settings
        c = connection.cursor()
        c.execute("DROP DATABASE " + settings.DATABASE_NAME)
        c.execute("CREATE DATABASE " + settings.DATABASE_NAME)
        print 'Created new database: %s' % settings.DATABASE_NAME
        c.close()

More like this

  1. backupdb command by msaelices 3 years, 7 months ago
  2. syncdata command by graham 3 years, 6 months ago
  3. manage.py reboot by givity 1 month, 1 week ago
  4. Continuous Integration command by berto 2 years, 3 months ago
  5. streaming serializer by kcarnold 2 years, 10 months ago

Comments

(Forgotten your password?)