diff --git a/Backend/postgres_connector.py b/Backend/postgres_connector.py index 7a34254..8a79dd2 100644 --- a/Backend/postgres_connector.py +++ b/Backend/postgres_connector.py @@ -6,7 +6,6 @@ import psycopg2.extras from config import load_config - # important do not store password when dealing with real database # might want to consider SQL injection down the line # gets all systems from the database @@ -20,13 +19,15 @@ class PostgresConnector: connection: A psycopg2 connection object to interact with the database. """ def __init__(self): - self.connection = psycopg2.connect( - host='localhost', - dbname='dad', - user='dad_user', - password='dad_pass', - port='5432' - ) + config = load_config() + try: + # connecting to the PostgreSQL server + self.connection = psycopg2.connect(**config) + print('Connected to the PostgreSQL server.') + + except (psycopg2.DatabaseError, Exception) as error: + print(error) + def construct_label(self, data): return (