X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/2f73bb36435c6e1a9b84745b4763a063e6391602..e6d9485c4ae566896f4e9e474d7d3588bc7b4b25:/nominatim/config.py diff --git a/nominatim/config.py b/nominatim/config.py index 911c7ddf..458c828f 100644 --- a/nominatim/config.py +++ b/nominatim/config.py @@ -29,6 +29,18 @@ class Configuration: return os.environ.get(name) or self._config[name] + def get_libpq_dsn(self): + """ Get configured database DSN converted into the key/value format + understood by libpq and psycopg. + """ + dsn = self.DATABASE_DSN + + if dsn.startswith('pgsql:'): + # Old PHP DSN format. Convert before returning. + return dsn[6:].replace(';', ' ') + + return dsn + def get_os_env(self): """ Return a copy of the OS environment with the Nominatim configuration merged in.