]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/clicmd/freeze.py
replace add-data function with native Python code
[nominatim.git] / nominatim / clicmd / freeze.py
1 """
2 Implementation of the 'freeze' subcommand.
3 """
4
5 from nominatim.db.connection import connect
6
7 # Do not repeat documentation of subcommand classes.
8 # pylint: disable=C0111
9 # Using non-top-level imports to avoid eventually unused imports.
10 # pylint: disable=E0012,C0415
11
12 class SetupFreeze:
13     """\
14     Make database read-only.
15
16     About half of data in the Nominatim database is kept only to be able to
17     keep the data up-to-date with new changes made in OpenStreetMap. This
18     command drops all this data and only keeps the part needed for geocoding
19     itself.
20
21     This command has the same effect as the `--no-updates` option for imports.
22     """
23
24     @staticmethod
25     def add_args(parser):
26         pass # No options
27
28     @staticmethod
29     def run(args):
30         from ..tools import freeze
31
32         with connect(args.config.get_libpq_dsn()) as conn:
33             freeze.drop_update_tables(conn)
34         freeze.drop_flatnode_file(args.config.FLATNODE_FILE)
35
36         return 0