title: How to create test Postgres db in flask-tesing
body: <p>I am using flask-testing to do some unit tests on a Postgres application. According to <a href="https://pythonhosted.org/Flask-Testing" rel="nofollow noreferrer">doc</a> , I have following code.</p>
  <pre><code>from flask_testing import TestCase
  from src.game.models import db
  from src import create_app    
  class BaseTest(TestCase):
      SQLALCHEMY_DATABASE_URI = 'postgresql://demo:demo@postgres:5432/test_db'
      TESTING = True
  
      def create_app(self):
          # pass in test configuration
          return create_app(self)
  
      def setUp(self):
          db.create_all()
  
      def tearDown(self):
          db.session.remove()
          db.drop_all()
  </code></pre>
  <p>Of course I got this error</p>
  <blockquote>
  <p>sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL:
  database &quot;test_db&quot; does not exist</p>
  </blockquote>
  <p>I do have a database <code>postgresql://demo:demo@postgres:5432/demo</code> which is my production database.</p>
  <p>How can I create <code>test_db</code> in this <code>BaseTest</code> class? I am using Python 3.6 and latest flask and flask-sqlalchemy. Thank you very much.</p>