diff --git a/dspace_statistics_api/config.py b/dspace_statistics_api/config.py index 289fb06..31b1ea0 100644 --- a/dspace_statistics_api/config.py +++ b/dspace_statistics_api/config.py @@ -7,5 +7,6 @@ DATABASE_NAME = os.environ.get('DATABASE_NAME', 'dspacestatistics') DATABASE_USER = os.environ.get('DATABASE_USER', 'dspacestatistics') DATABASE_PASS = os.environ.get('DATABASE_PASS', 'dspacestatistics') DATABASE_HOST = os.environ.get('DATABASE_HOST', 'localhost') +DATABASE_PORT = os.environ.get('DATABASE_PORT', '5432') # vim: set sw=4 ts=4 expandtab: diff --git a/dspace_statistics_api/database.py b/dspace_statistics_api/database.py index 3dae8ec..73ee022 100644 --- a/dspace_statistics_api/database.py +++ b/dspace_statistics_api/database.py @@ -2,10 +2,11 @@ from .config import DATABASE_NAME from .config import DATABASE_USER from .config import DATABASE_PASS from .config import DATABASE_HOST +from .config import DATABASE_PORT import psycopg2, psycopg2.extras def database_connection(): - connection = psycopg2.connect("dbname={} user={} password={} host='{}'".format(DATABASE_NAME, DATABASE_USER, DATABASE_PASS, DATABASE_HOST), cursor_factory=psycopg2.extras.DictCursor) + connection = psycopg2.connect("dbname={} user={} password={} host='{}' port={}".format(DATABASE_NAME, DATABASE_USER, DATABASE_PASS, DATABASE_HOST, DATABASE_PORT), cursor_factory=psycopg2.extras.DictCursor) return connection