title: Django: Setting up multiple databases using sqlite3
body: <p>I have been trying to setup my project on Django1.3 to use multiple databases, in my case different sqlite3 files. I have been reading the Django documentation as well a lot of googling but in vain.</p>
  
  <p><strong>Problems faced</strong></p>
  
  <ol>
  <li>When using the syncdb with --database, why the tables for that particular application are not getting created in either default database or the other db?</li>
  <li>Django framework internal tables like auth are getting created for all the databases mentioned. Is this the way the feature is supposed to behave OR I have wrongly configured the same?</li>
  </ol>
  
  <p><strong>My Code</strong></p>
  
  <p><em><strong>settings.py</em></strong></p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(SITE_ROOT, "db/defaultdb.sqlite"),
      },
      'app1': {
               'ENGINE': 'django.db.backends.sqlite3',
               'NAME': os.path.join(SITE_ROOT, "db/app1db.sqlite"),
      }
  }
  
  DATABASE_ROUTERS = ['dbrouter.MyAppRouter']
  </code></pre>
  
  <p><strong>dbrouter.py</strong></p>
  
  <pre><code>class MyAppRouter(object):
      def db_for_read(self, model, **hints):
          if model._meta.app_label == 'app1':
              return 'app1db'
          return None
  
      def db_for_write(self, model, **hints):
          if model._meta.app_label == 'app1':
              return 'app1db'
          return None
  
      def allow_syncdb(self, db, model):
          if db == 'app1db':
              return model._meta.app_label == 'app1'
          elif model._meta.app_label == 'app1':
              return False
          return None
  </code></pre>
  
  <p>Thanks everyone for your time.</p>