[config] add port-config for database

This commit is contained in:
Tim Gröger 2021-02-10 21:21:53 +01:00
parent 06237754f1
commit 29157dbc03
1 changed files with 3 additions and 2 deletions

View File

@ -9,7 +9,7 @@ from flaschengeist import _module_path, logger
# Default config: # Default config:
config = {} config = {"DATABASE": {"port": 3306}}
def update_dict(d, u): def update_dict(d, u):
@ -66,11 +66,12 @@ def configure_app(app, test_config=None):
app.config["SECRET_KEY"] = config["FLASCHENGEIST"]["secret_key"] app.config["SECRET_KEY"] = config["FLASCHENGEIST"]["secret_key"]
if test_config is None: if test_config is None:
app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://{user}:{passwd}@{host}/{database}".format( app.config["SQLALCHEMY_DATABASE_URI"] = "mysql://{user}:{passwd}@{host}:{port}/{database}".format(
user=config["DATABASE"]["user"], user=config["DATABASE"]["user"],
passwd=config["DATABASE"]["password"], passwd=config["DATABASE"]["password"],
host=config["DATABASE"]["host"], host=config["DATABASE"]["host"],
database=config["DATABASE"]["database"], database=config["DATABASE"]["database"],
port=config["DATABASE"]["port"],
) )
else: else:
app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite+pysqlite://{config['DATABASE']['file_path']}" app.config["SQLALCHEMY_DATABASE_URI"] = f"sqlite+pysqlite://{config['DATABASE']['file_path']}"