Last Updated: February 25, 2016
·
667
· paperaeroplain

Syncing multiple Django databases in Visual Studio 2013

The context menu in Visual Studio 2013 (solution explorer>project>context menu>django>sync db) only allows you to sync the 'default' database.

If you define multiple databases within your settings, and want Django to sync one of these, you can use the command line to sync these.

First, in command prompt, navigate to the Scripts folder within the appropriate Python environment beneath your solution/project, then:

1. Activate the environment

c:\mydjangoproject\myenv\scripts\activate.bat

2. Run the sync

(myenv) c:\mydjangoproject\myenv\scripts\python ..\..\manage.py syncdb --database=databaseConnectionName

Where databaseConnectionName is the name of the database connection name you want to sync

The above assumes you have Python in the same folder, or have it set in the PATH environment settings.

3. Deactivate when you've finished

(myenv) c:\mydjangoproject\myenv\scripts\deactivate.bat