From 1c2a11cbc10ac14257bc5ef4592aff83c293c607 Mon Sep 17 00:00:00 2001
From: Simon Oehrl <oehrl@vr.rwth-aachen.de>
Date: Sat, 4 Apr 2020 19:26:50 +0200
Subject: [PATCH] Fix database host

---
 access_node/__main__.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/access_node/__main__.py b/access_node/__main__.py
index 39dfd78..588b34d 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")
-- 
GitLab