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
- backupdb command by msaelices 3 years, 7 months ago
- syncdata command by graham 3 years, 6 months ago
- manage.py reboot by givity 1 month, 1 week ago
- Continuous Integration command by berto 2 years, 3 months ago
- streaming serializer by kcarnold 2 years, 10 months ago
Comments