Skip to content
Snippets Groups Projects
Commit 324c548b authored by Simon Oehrl's avatar Simon Oehrl
Browse files

Add try-catch blocks

parent 82411c01
Branches
No related tags found
No related merge requests found
Pipeline #163367 passed
......@@ -14,8 +14,11 @@ import psycopg2
def ConnectToDatabase(postgres_username, postgres_password):
database_host = 'database'
try:
with open('database_host.txt') as database_host_file:
database_host = database_host_file.readline().rstrip('\n')
except:
pass
return psycopg2.connect(database="postgres", user="postgres",
password="postgres", host=database_host, port="5432")
......
......@@ -16,8 +16,11 @@ import numpy as np
def connect_to_database():
database_host = 'database'
try:
with open('database_host.txt') as database_host_file:
database_host = database_host_file.readline().rstrip('\n')
except:
pass
return psycopg2.connect(database="postgres", user="postgres",
password="postgres", host=database_host, port="5432")
......
......@@ -16,8 +16,11 @@ import numpy as np
def connect_to_database():
database_host = 'database'
try:
with open('database_host.txt') as database_host_file:
database_host = database_host_file.readline().rstrip('\n')
except:
pass
return psycopg2.connect(database="postgres", user="postgres",
password="postgres", host=database_host, port="5432")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment