title: How to dbchange mongo flask?
body: <p>I have a flask based application that I am configuring like:</p>
  
  <pre><code>from flask import Flask
  from flask.ext.mongoengine import MongoEngine
  
  app = Flask(__name__)
  app.config["MONGODB_DB"] = "my_tumble_log"
  app.config["SECRET_KEY"] = "KeepThisS3cr3t"
  
  db = MongoEngine(app)
  
  if __name__ == '__main__':
      app.run()
  </code></pre>
  
  <p>I have a models.py file that contains all my models kind of like: import datetime</p>
  
  <pre><code>from flask import url_for
  from tumblelog import db
  
  
  class Post(db.Document):
      created_at = db.DateTimeField(default=datetime.datetime.now, required=True)
      title = db.StringField(max_length=255, required=True)
      slug = db.StringField(max_length=255, required=True)
      body = db.StringField(required=True)
      comments = db.ListField(db.EmbeddedDocumentField('Comment'))
  
      def get_absolute_url(self):
          return url_for('post', kwargs={"slug": self.slug})
  
      def __unicode__(self):
          return self.title
  
      meta = {
          'allow_inheritance': True,
          'indexes': ['-created_at', 'slug'],
          'ordering': ['-created_at']
      }
  </code></pre>
  
  <p>I want to define a new route such that I can use another database and its collections there:</p>
  
  <pre><code>@app.route('/sampleroute')
  def sample_route():
      #Insert Code to use another database of a specific name
      #Query Out a particular "OtherClass" that would be in models.py
  </code></pre>
  
  <p>What do I need to do to be able to set "db" equal to some other database like "db1" instead of "my_tumble_log" for just within that "/sampleroute"? Can I declare "OtherClass" within its own class like Post does in the same models.py file? Or is what I want to do not doable with MongoEngine?</p>