+ refresh.setup_website(webdir, args.config, conn)
+
+ self._finalize_database(args.config.get_libpq_dsn(), args.offline)
+
+ return 0
+
+
+ def _setup_tables(self, config: Configuration, reverse_only: bool) -> None:
+ """ Set up the basic database layout: tables, indexes and functions.
+ """
+ from ..tools import database_import, refresh
+
+ with connect(config.get_libpq_dsn()) as conn:
+ LOG.warning('Create functions (1st pass)')
+ refresh.create_functions(conn, config, False, False)
+ LOG.warning('Create tables')
+ database_import.create_tables(conn, config, reverse_only=reverse_only)
+ refresh.load_address_levels_from_config(conn, config)
+ LOG.warning('Create functions (2nd pass)')
+ refresh.create_functions(conn, config, False, False)
+ LOG.warning('Create table triggers')
+ database_import.create_table_triggers(conn, config)
+ LOG.warning('Create partition tables')
+ database_import.create_partition_tables(conn, config)
+ LOG.warning('Create functions (3rd pass)')
+ refresh.create_functions(conn, config, False, False)
+
+
+ def _get_tokenizer(self, continue_at: Optional[str],
+ config: Configuration) -> AbstractTokenizer:
+ """ Set up a new tokenizer or load an already initialised one.
+ """
+ from ..tokenizer import factory as tokenizer_factory
+
+ if continue_at in ('import-from-file', 'load-data', None):
+ # (re)initialise the tokenizer data
+ return tokenizer_factory.create_tokenizer(config)
+
+ # just load the tokenizer
+ return tokenizer_factory.get_tokenizer_for_db(config)
+
+
+ def _finalize_database(self, dsn: str, offline: bool) -> None:
+ """ Determine the database date and set the status accordingly.
+ """
+ with connect(dsn) as conn:
+ properties.set_property(conn, 'database_version', str(NOMINATIM_VERSION))
+