diff --git a/README.md b/README.md index 2fb0a6d..41a007a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,5 @@ Ein erster Gedanke des Datenbank-Layouts sieht folgendermaßen aus: ### Postman - Zum Debuggen der Flask App verwende ich dieses Tutorial: -https://code.visualstudio.com/docs/python/tutorial-flask#_create-a-project-environment-for-the-flask-tutorial - +https://code.visualstudio.com/docs/python/tutorial-flask#_create-a-project-environment-for-the-flask-tutorial \ No newline at end of file diff --git a/docs/BremenCalling_Datenmodell.xlsx b/docs/BremenCalling_Datenmodell.xlsx index 2c102a1..09f36b6 100644 Binary files a/docs/BremenCalling_Datenmodell.xlsx and b/docs/BremenCalling_Datenmodell.xlsx differ diff --git a/docs/UserStories.xlsx b/docs/UserStories.xlsx index 4caf01e..8071ec9 100644 Binary files a/docs/UserStories.xlsx and b/docs/UserStories.xlsx differ diff --git a/src/server/BreCal/connection_data.json b/src/server/BreCal/connection_data.json new file mode 100644 index 0000000..f07690d --- /dev/null +++ b/src/server/BreCal/connection_data.json @@ -0,0 +1,9 @@ +{ +"host" : "lager", +"port" : 3306, +"user" : "ds", +"password" : "HalloWach23", +"pool_name" : "brecal_pool", +"pool_size" : 20, +"database" : "bremen_calling" +} \ No newline at end of file diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index ed115a8..7c38aeb 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -1,21 +1,25 @@ import mysql.connector import pydapper import logging +import json +import os connection_pool = None def initPool(): try: global connection_pool - connection_pool = mysql.connector.connect( - host="lager", # TODO: move these settings outside the code! - port=3306, - user="ds", - password="HalloWach23", - pool_name="brecal_pool", - pool_size=20, - database="bremen_calling" - ) + + config_path = './src/server/BreCal/connection_data.json' + print (os.getcwd()) + if not os.path.exists(config_path): + print ('cannot find ' + config_path) + exit(1) + + f = open(config_path); + connection_data = json.load(f) + + connection_pool = mysql.connector.connect(**connection_data) commands = pydapper.using(connection_pool) data = commands.query_single("SELECT id from `user`") @@ -23,4 +27,6 @@ def initPool(): except mysql.connector.PoolError as e: logging.error(f"Failed to create connection pool: {e}") + print(e) + except e: print(e) \ No newline at end of file