]> git.openstreetmap.org Git - nominatim.git/blobdiff - nominatim/clicmd/freeze.py
Improved performance of the postcodes query and some code cleaning
[nominatim.git] / nominatim / clicmd / freeze.py
index 8bca04b995f1240782ab27c92e4326db2f1ad9f3..8a6c928e7f3ade5ec8e5c06cfcc089853358d578 100644 (file)
@@ -2,7 +2,7 @@
 Implementation of the 'freeze' subcommand.
 """
 
 Implementation of the 'freeze' subcommand.
 """
 
-from ..db.connection import connect
+from nominatim.db.connection import connect
 
 # Do not repeat documentation of subcommand classes.
 # pylint: disable=C0111
 
 # Do not repeat documentation of subcommand classes.
 # pylint: disable=C0111
@@ -29,9 +29,8 @@ class SetupFreeze:
     def run(args):
         from ..tools import freeze
 
     def run(args):
         from ..tools import freeze
 
-        conn = connect(args.config.get_libpq_dsn())
-        freeze.drop_update_tables(conn)
+        with connect(args.config.get_libpq_dsn()) as conn:
+            freeze.drop_update_tables(conn)
         freeze.drop_flatnode_file(args.config.FLATNODE_FILE)
         freeze.drop_flatnode_file(args.config.FLATNODE_FILE)
-        conn.close()
 
         return 0
 
         return 0