]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/config.py
cli: import python modules for commands on demand
[nominatim.git] / nominatim / config.py
index 911c7ddf127f68f438ab582c75fa38d5ed469dd8..458c828f58fce8adeda02fd550823641366ceb2c 100644 (file)
@@ -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.