Hello everyone

I am working on a project where we have multiple databases instance. We
wanted a script to run through all databases to perform syncdb command. I
tried looking on net but could not find one. So we decided to develop one on
our own. I would like to share that script with the group as i have learned
a lot from this group. Please find the script below.

    def multidb_sync(self):
        acc_list = ['']
        from account.models.accounts import Account
        from django.core.management import call_command
        accounts = Account.objects.all();
        for account in accounts:
            acc_list.append(account.subdomain)


        call_command('syncdb', verbosity=1)
        for dbname in acc_list:
            connection.settings_dict['DATABASE_NAME'] = dbname
            call_command('syncdb', verbosity=1)

I hope it helps. If you want complete script, please let me know I would be
glad to post it on this group.

*BootStrapToday <http://www.bootstraptoday.com>*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to