Advertisement
McSpiffing

flask-tdd-docker_heroku-postgresql-fix

Apr 11th, 2021
1,094
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. # src/config.py
  2.  
  3.  
  4. import os
  5.  
  6. class BaseConfig:
  7.     TESTING = False
  8.     SQLALCHEMY_TRACK_MODIFICATIONS = False
  9.     SECRET_KEY = 'my_precious'
  10.  
  11.  
  12. class DevelopmentConfig(BaseConfig):
  13.     SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
  14.  
  15.  
  16. class TestingConfig(BaseConfig):
  17.     TESTING = True
  18.     SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_TEST_URL')
  19.  
  20.  
  21. class ProductionConfig(BaseConfig):
  22.     url = os.environ.get('DATABASE_URL')
  23.     if url.startswith("postgres://"):
  24.         url = url.replace("postgres://", "postgresql://", 1)
  25.     SQLALCHEMY_DATABASE_URI = url
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement