Skip to content

Commit

Permalink
fix broken connection string after conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
saikonen committed Oct 25, 2023
1 parent 379b21b commit 3c3385c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions services/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ def connection_string_url(self, type=None):
elif type == DBType.READER:
base_url = f'postgresql://{quote(self._user)}:{quote(self._password)}@{self._read_replica_host}:{self._port}/{self._database_name}'

if (self._ssl_mode in ['allow', 'prefer', 'require', 'verify-ca', 'verify-full']):
ssl_query = f'sslmode={self._ssl_mode}'
if self._ssl_cert_path is not None:
ssl_query = f'{ssl_query}&sslcert={self._ssl_cert_path}'
if self._ssl_key_path is not None:
ssl_query = f'{ssl_query}&sslkey={self._ssl_key_path}'
if self._ssl_root_cert_path is not None:
ssl_query = f'{ssl_query}&sslrootcert={self._ssl_root_cert_path}'
else:
ssl_query = f'sslmode=disable'

return f'{base_url}?{ssl_query}'

def get_dsn(self, type=None):
Expand Down

0 comments on commit 3c3385c

Please sign in to comment.