From bd75ecc6efb2c21a6efbec9b74c53b43fcae03eb Mon Sep 17 00:00:00 2001 From: Matthew Welch Date: Wed, 14 Jul 2021 17:07:22 -0700 Subject: [PATCH] Allow connection string to be overridden by environment variable Remove NullPool left over from using sqlite --- database.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/database.py b/database.py index f570342..5e7d0ce 100644 --- a/database.py +++ b/database.py @@ -13,11 +13,12 @@ from sqlalchemy.dialects.postgresql import BYTEA from sqlalchemy.exc import IntegrityError from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import scoped_session, sessionmaker -from sqlalchemy.pool import NullPool from sqlalchemy.sql.expression import cast from werkzeug.security import check_password_hash -engine = create_engine("***REMOVED***", poolclass=NullPool) +DB_URL = os.environ.get("CONNECTION_STRING", "***REMOVED***") + +engine = create_engine(DB_URL) logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) session_factory = sessionmaker(bind=engine) Session = scoped_session(session_factory)