From bb503828098717825c389fd6f450b395a02dcc6a Mon Sep 17 00:00:00 2001 From: clerie Date: Sun, 24 Jan 2021 16:28:18 +0100 Subject: [PATCH] Move config object to config file --- README.md | 7 +++++-- wetter/__init__.py | 6 +++--- wetter/config/__init__.py | 0 wetter/config/db.py.example | 4 ---- 4 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 wetter/config/__init__.py delete mode 100644 wetter/config/db.py.example diff --git a/README.md b/README.md index 4ccf12d..7d44a7b 100644 --- a/README.md +++ b/README.md @@ -12,11 +12,14 @@ Nur ein Mal zu initialisieren: git clone https://github.com/clerie/wetter.git cd wetter/ virtualenv -p python3 ENV -cp wetter/config/db.py.example wetter/config/db.py cd .. ``` -Passe nun `wetter/config/db.py` mit deinen Datenbankzugangsdaten an. +Erstelle eine `config.cfg` mit folgendem Inhalt und passe die Werte entsprechend an. + +``` +SQLALCHEMY_DATABASE_URI=postgresql://user:password@host:5432/database +``` Bei Bedarf musst du noch die `wsgi.ini` anpassen. diff --git a/wetter/__init__.py b/wetter/__init__.py index 777b515..63b5005 100644 --- a/wetter/__init__.py +++ b/wetter/__init__.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from wetter.config.db import db as config_db - from flask import Flask from flask_sqlalchemy import SQLAlchemy import flask_excel as excel @@ -10,7 +8,9 @@ app = Flask(__name__) excel.init_excel(app) app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False -app.config["SQLALCHEMY_DATABASE_URI"] = config_db['uri'] + +# override configs from file +app.config.from_envvar('WETTER_SETTINGS') db = SQLAlchemy(app) diff --git a/wetter/config/__init__.py b/wetter/config/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/wetter/config/db.py.example b/wetter/config/db.py.example deleted file mode 100644 index ee98e5b..0000000 --- a/wetter/config/db.py.example +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python3 - -db = {} -db['uri'] = "postgresql://user:password@host:5432/database"