diff --git a/access_node/__main__.py b/access_node/__main__.py index 39dfd78630800656f150cabfcd7b98e173cd13b2..588b34d33072b71d849cf801185d3240a632cf8c 100644 --- a/access_node/__main__.py +++ b/access_node/__main__.py @@ -12,9 +12,12 @@ import time import requests import psycopg2 -def ConnectToDatabase(postgres_username, postgres_password, port): - return psycopg2.connect(database="postgres", user=postgres_username, - password=postgres_password, host="database", port=str(port)) +def ConnectToDatabase(postgres_username, postgres_password): + database_host = 'database' + with open('database_host.txt') as database_host_file: + database_host = database_host_file.readline() + return psycopg2.connect(database="postgres", user="postgres", + password="postgres", host=database_host, port="5432") def main(): @@ -22,7 +25,7 @@ def main(): time.sleep(5) # get simulation nodes - con = ConnectToDatabase('postgres', 'postgres', 5432) + con = ConnectToDatabase('postgres', 'postgres') cur = con.cursor() # NEST cur.execute("SELECT address FROM nest_simulation_node")