title: Flask: How to manage different environment databases?
body: <p>I am working on an app which looks similar to</p>
  
  <pre><code>facebook/
           __init__.py
           feed/
               __init__.py
               business.py
               views.py
               models/
                      persistence.py
                      user.py
           chat/
               __init__.py
               models.py
               business.py
               views.py
           config/
                  dev.py
                  test.py
                  prod.py 
  </code></pre>
  
  <p>I want to have three environments <code>Dev</code>, <code>Test</code> and <code>Production</code>.<br>
  I have the following requirements:<br>
  a.) When I start the server <code>python runserver.py</code>, I would like to mention which environment I want to connect - <code>Dev</code>, <code>Test</code> or <code>Production</code>.<br>
  b.) <code>Dev</code> &amp; <code>Production</code> should have the schema built and just need to connect to machine<br>
  c.) I would also like for my test to connect to <code>sqlite db</code>, and create the schema, run tests  </p>
  
  <p>How can I achieve this in a configuration manner so that I do not have to hardcode anything related to database.</p>
  
  <p>Are there any good patterns available in flask?</p>
  
  <p>Currently my <code>runerver.py</code> has hardcoding for environment that I don't like,</p>
  
  <pre><code>app = Flask(__name__)
  app.config['SECRET_KEY'] = dev.SECRET_KEY
  </code></pre>
  
  <p>I am looking for better ideas than I have</p>