From 2c173f984844796d18a0a3d582d8fa8a96173cdc Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Sat, 25 Mar 2017 13:05:44 -0700 Subject: [PATCH] Read dbpath from $CALIBRE_DBPATH if present This is an exploration in potentially enabling multiple libraries to run using the same engine. Since app config is all in the db, we should get no port conflicts and be able to run multiple instances of this app with no issues. Using os.getenv instead of os.environ.get allows us to provide CALIBRE_DBPATH inline with the invocation of the file (`CALIBRE_DBPATH=/foo/bar/` python cps.py) --- cps/ub.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cps/ub.py b/cps/ub.py index 370b373a..712a448e 100644 --- a/cps/ub.py +++ b/cps/ub.py @@ -13,7 +13,7 @@ from flask_babel import gettext as _ import json #from builtins import str -dbpath = os.path.join(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + os.sep + ".." + os.sep), "app.db") +dbpath = os.path.join(os.path.normpath(os.getenv("CALIBRE_DBPATH", os.path.dirname(os.path.realpath(__file__)) + os.sep + ".." + os.sep)), "app.db") engine = create_engine('sqlite:///{0}'.format(dbpath), echo=False) Base = declarative_base()