]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/db/connection.py
Updated check to see if osm_file is set
[nominatim.git] / nominatim / db / connection.py
index fce897bc7250c814d6679188a5c6281a8ac3790c..82801ae7995c9d1e5527baec0d9dd89c85e70e4d 100644 (file)
@@ -174,6 +174,15 @@ class Connection(psycopg2.extensions.connection):
 
         return (int(version_parts[0]), int(version_parts[1]))
 
+
+    def extension_loaded(self, extension_name: str) -> bool:
+        """ Return True if the hstore extension is loaded in the database.
+        """
+        with self.cursor() as cur:
+            cur.execute('SELECT extname FROM pg_extension WHERE extname = %s', (extension_name, ))
+            return cur.rowcount > 0
+
+
 class ConnectionContext(ContextManager[Connection]):
     """ Context manager of the connection that also provides direct access
         to the underlying connection.