diff --git a/services/solr-names-updater/config.py b/services/solr-names-updater/config.py index 68c816b23..752cd1430 100644 --- a/services/solr-names-updater/config.py +++ b/services/solr-names-updater/config.py @@ -74,13 +74,10 @@ class Config(): # pylint: disable=too-few-public-methods DB_NAME = os.getenv('DATABASE_NAME', '') DB_HOST = os.getenv('DATABASE_HOST', '') DB_PORT = os.getenv('DATABASE_PORT', '5432') - SQLALCHEMY_DATABASE_URI = 'postgresql://{user}:{password}@{host}:{port}/{name}'.format( - user=DB_USER, - password=DB_PASSWORD, - host=DB_HOST, - port=int(DB_PORT), - name=DB_NAME, - ) + if DB_UNIX_SOCKET := os.getenv('DATABASE_UNIX_SOCKET', None): + SQLALCHEMY_DATABASE_URI = f'postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?host={DB_UNIX_SOCKET}' + else: + SQLALCHEMY_DATABASE_URI = f'postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}' GCP_AUTH_KEY = os.getenv('BUSINESS_GCP_AUTH_KEY', None) EMAILER_TOPIC = os.getenv('NAMEX_MAILER_TOPIC', '')