From 2c82699263dc8a932b3ce69426f77cdb731f0a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Morossini?= Date: Wed, 5 Jul 2023 16:27:39 -0300 Subject: [PATCH] updated config.py --- config.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index ca45a5a..7a87e9c 100644 --- a/config.py +++ b/config.py @@ -1,11 +1,11 @@ # External dependencies import os +import re from dotenv import load_dotenv, find_dotenv # Setting up environment _ = load_dotenv(find_dotenv()) # read local .env file - # Creating Config class class Config(object): # Defining the path to the database @@ -13,7 +13,11 @@ class Config(object): database_path = os.path.join(root_folder, 'instance', 'database.db') # Database - SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL') # Connecting app to the database + DATABASE_URL = os.getenv('DATABASE_URL') # Connecting app to the database + if DATABASE_URL and DATABASE_URL.startswith("postgres://"): + DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://", 1) + SQLALCHEMY_DATABASE_URI = DATABASE_URL + SECRET_KEY = os.getenv('SECRET_KEY') # Mail MAIL_SERVER = 'smtp.googlemail.com' @@ -29,9 +33,10 @@ class Config(object): class DevelopmentConfig(Config): DEBUG = True TESTING = False + SQLALCHEMY_DATABASE_URI = f"sqlite:///{Config.database_path}" # Production Environment class ProductionConfig(Config): DEBUG = False - TESTING = False + TESTING = False \ No newline at end of file