]> git.openstreetmap.org Git - nominatim.git/blob - nominatim/clicmd/freeze.py
Merge pull request #2562 from lonvia/copyright-headers
[nominatim.git] / nominatim / clicmd / freeze.py
1 # SPDX-License-Identifier: GPL-2.0-only
2 #
3 # This file is part of Nominatim. (https://nominatim.org)
4 #
5 # Copyright (C) 2022 by the Nominatim developer community.
6 # For a full list of authors see the git log.
7 """
8 Implementation of the 'freeze' subcommand.
9 """
10
11 from nominatim.db.connection import connect
12
13 # Do not repeat documentation of subcommand classes.
14 # pylint: disable=C0111
15 # Using non-top-level imports to avoid eventually unused imports.
16 # pylint: disable=E0012,C0415
17
18 class SetupFreeze:
19     """\
20     Make database read-only.
21
22     About half of data in the Nominatim database is kept only to be able to
23     keep the data up-to-date with new changes made in OpenStreetMap. This
24     command drops all this data and only keeps the part needed for geocoding
25     itself.
26
27     This command has the same effect as the `--no-updates` option for imports.
28     """
29
30     @staticmethod
31     def add_args(parser):
32         pass # No options
33
34     @staticmethod
35     def run(args):
36         from ..tools import freeze
37
38         with connect(args.config.get_libpq_dsn()) as conn:
39             freeze.drop_update_tables(conn)
40         freeze.drop_flatnode_file(str(args.config.get_path('FLATNODE_FILE')))
41
42         return 0