Example #1
0
File: clear.py Project: gehan/cotd
 def handle_noargs(self, **options):
     cursor = connection.cursor()
     cursor.execute("DROP DATABASE `%s`"%settings.DATABASES['default']['NAME'])
     cursor.execute("CREATE DATABASE `%s` CHARACTER SET='utf8' COLLATE='utf8_general_ci'"%settings.DATABASES['default']['NAME'])
     cursor.execute("USE `%s`"%settings.DATABASES['default']['NAME'])
     sync = SyncCommand()
     sync.handle_noargs()
     setup_data.setup()
    def sync_tenant_apps(self, apps, schema_name=None):
        self._set_managed_apps(apps)
        syncdb_command = SyncdbCommand()
        if schema_name:
            print self.style.NOTICE("=== Running syncdb for schema: %s" % schema_name)
            sync_tenant = get_tenant_model().objects.filter(schema_name=schema_name).get()
            connection.set_tenant(sync_tenant, include_public=True)
            syncdb_command.execute(**self.options)
        else:
            public_schema_name = get_public_schema_name()
            tenant_schemas_count = get_tenant_model().objects.exclude(schema_name=public_schema_name).count()
            if not tenant_schemas_count:
                raise CommandError("No tenant schemas found")

            for tenant_schema in get_tenant_model().objects.exclude(schema_name=public_schema_name).all():
                print self.style.NOTICE("=== Running syncdb for schema %s" % tenant_schema.schema_name)
                try:
                    connection.set_tenant(tenant_schema, include_public=True)
                    syncdb_command.execute(**self.options)
                except Exception as e:
                    print e
def _syncdb():
    print "syncdb"
    sync = Command()
    sync.handle()
    print "done syncdb"    
def _syncdb():
    sync = Command()
    sync.handle()
        
Example #5
0
def _syncdb():
    sync = Command()
    sync.handle()
        
Example #6
0
 def testSetUp(self):
     from django.db import connection
     from django.core.management.commands.syncdb import Command as SyncDB
     syncdb = SyncDB()
     syncdb.handle()
     connection.cursor()