From d115eb47b69de1fb84e872a7872bf1fa0cf609c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Tue, 24 Apr 2018 11:30:39 +0200 Subject: [PATCH] Move database to a permanent location --- .gitignore | 1 + backend/quote.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..90f4cd8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +quotes.db diff --git a/backend/quote.py b/backend/quote.py index f80abeb..c6e5274 100644 --- a/backend/quote.py +++ b/backend/quote.py @@ -1,3 +1,5 @@ +import os + import marshmallow import sqlalchemy import sqlalchemy.orm @@ -6,7 +8,9 @@ import sqlalchemy.ext.declarative from datetime import datetime -engine = sqlalchemy.create_engine('sqlite:////tmp/quotes.db') # FIXME +DB_PATH = os.path.expandvars('$HOME/quotes/quotes.db') + +engine = sqlalchemy.create_engine(f'sqlite:///{DB_PATH}') Session = sqlalchemy.orm.sessionmaker(bind=engine) Base = sqlalchemy.ext.declarative.declarative_base()