]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/tools/freeze.py
force a fixed pool size and make it configurable
[nominatim.git] / nominatim / tools / freeze.py
index b0ebb2c08f8c872b4147a2b4eaecadccfd1df0bd..602def55b55ac3bb8b52212d43cab04d2361f37b 100644 (file)
@@ -7,10 +7,13 @@
 """
 Functions for removing unnecessary data from the database.
 """
+from typing import Optional
 from pathlib import Path
 
 from psycopg2 import sql as pysql
 
+from nominatim.db.connection import Connection
+
 UPDATE_TABLES = [
     'address_levels',
     'gb_postcode',
@@ -25,7 +28,7 @@ UPDATE_TABLES = [
     'wikipedia_%'
 ]
 
-def drop_update_tables(conn):
+def drop_update_tables(conn: Connection) -> None:
     """ Drop all tables only necessary for updating the database from
         OSM replication data.
     """
@@ -42,8 +45,14 @@ def drop_update_tables(conn):
     conn.commit()
 
 
-def drop_flatnode_file(fpath):
+def drop_flatnode_file(fpath: Optional[Path]) -> None:
     """ Remove the flatnode file if it exists.
     """
     if fpath and fpath.exists():
         fpath.unlink()
+
+def is_frozen(conn: Connection) -> bool:
+    """ Returns true if database is in a frozen state
+    """
+
+    return conn.table_exists('place') is False