Using different dbs on production and test environment
<p>I want to use a test db on my test environment, and the production db on production environment in my Python application.</p>

<p>How should I handle routing to two dbs? Should I have an untracked <code>config.yml</code> file that has the test db's connection string on my test server, and the production db's connection string on production server?</p>

<p>I'm using <code>github</code> for version control and <code>travis ci</code> for deployment.</p>

<p>Let's take Linux environment for example. Often, the user level configuration of an application is placed under your home folder as a dot file. So what you can do is like this:</p>

<ol>
<li>In your git repository, track a sample configure file, e.g., <code>config.sample.yaml</code>, and put the configuration structure here.</li>
<li>When deploying, either in test environment or production environment, you can copy and rename this file as a dot-file, e.g., <code>$HOME/.{app}.config.yaml</code>. Then in your application, you can read this file.</li>
</ol>

<p>If you are developing an python package, you can make the file copy operation done in the setup.py. There are some advantages:</p>

<ol>
<li>You can always track the structure changes of your configuration file.</li>
<li>Separate configuration between test and production enviroment.</li>
<li>More secure, you do not need to code your import db connection information in the public file.</li>
</ol>

<p>Hope this would be helpful. </p>

python github configuration travis-ci configuration-files