title: Flask Manage Dev Live Databases on Elastic Beanstalk
body: <p>I have a Flask app that I have deployed to AWS Elastic Beanstalk and all works well. However I currently have the SQLAlchemy connection string hard-coded as the live AWS string. I need now to set thing up so that the AWS server automatically picks up the correct string, and my local environment uses the dev (local string). I have been reading the following post on how to achieve this:</p>
  
  <p><a href="https://stackoverflow.com/questions/15603240/flask-how-to-manage-different-environment-databases">Flask: How to manage different environment databases?</a></p>
  
  <p>This makes sense in theory but I can't find any practical examples of how to actually achieve this on AWS Elastic Beanstalk. My <strong>init</strong>.py code looks like this:</p>
  
  <pre><code>from flask import Flask
  from flask_debugtoolbar import DebugToolbarExtension
  from flask_cors import CORS, cross_origin
  from flask_sqlalchemy import SQLAlchemy
  
  application = app = Flask(__name__)
  
  app.config.from_object('config')
  app.config.from_envvar('XXXXXPRODUCTION_CONFIG',silent=True)
  db = SQLAlchemy(app)
  CORS(app)
  </code></pre>
  
  <p>Config.py looks like this:</p>
  
  <pre><code>SQLALCHEMY_DATABASE_URI = 'mysql://root:xxxxxxx@localhost/xxxxx'
  SQLALCHEMY_TRACK_MODIFICATIONS = False
  DEBUG = True
  </code></pre>
  
  <p>And Config_production_dev.py looks like this:</p>
  
  <pre><code>SQLALCHEMY_DATABASE_URI = 'mysql://xxxxxx:xxxxxx@#########.cuhrbowyd8hk.eu-west-2.rds.amazonaws.com/ebdb'
  SQLALCHEMY_TRACK_MODIFICATIONS = False
  DEBUG = False
  </code></pre>
  
  <p>So everything is set up but I now have no idea how to initiate this part for the AWS instance:</p>
  
  <pre><code>app.config.from_envvar('XXXXXPRODUCTION_CONFIG',silent=True)
  </code></pre>
  
  <p>According to the post mentioned above I need something like this:</p>
  
  <p>environment=XXXXXPRODUCTION_CONFIG="/home/tigra/mycoolapp/settings_production.py"</p>
  
  <p>But is the path shown a path on my local machine? Or a path to my Elastic Beanstalk app? And if so how do I find the details of this path? Also how do I load this command up into the EB environment so that it executes? I can't find this information anywhere. Any help would be much appreciated.</p>
  
  <p>I'm deploying the app using eb deploy in eb cli.</p>