mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
rename sql directory to lib-sql
Also introduces a separate constant for the sql directory, so that it can be put separately from the rest of the data if required.
This commit is contained in:
@@ -68,7 +68,8 @@ class CommandlineParser:
|
||||
self.parser.print_help()
|
||||
return 1
|
||||
|
||||
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'):
|
||||
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'sqllib_dir',
|
||||
'data_dir', 'phpcgi_path'):
|
||||
setattr(args, arg, Path(kwargs[arg]))
|
||||
args.project_dir = Path(args.project_dir).resolve()
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class UpdateRefresh:
|
||||
if args.postcodes:
|
||||
LOG.warning("Update postcodes centroid")
|
||||
conn = connect(args.config.get_libpq_dsn())
|
||||
refresh.update_postcodes(conn, args.data_dir)
|
||||
refresh.update_postcodes(conn, args.sqllib_dir)
|
||||
conn.close()
|
||||
|
||||
if args.word_counts:
|
||||
@@ -70,7 +70,7 @@ class UpdateRefresh:
|
||||
if args.functions:
|
||||
LOG.warning('Create functions')
|
||||
conn = connect(args.config.get_libpq_dsn())
|
||||
refresh.create_functions(conn, args.config, args.data_dir,
|
||||
refresh.create_functions(conn, args.config, args.sqllib_dir,
|
||||
args.diffs, args.enable_debug_statements)
|
||||
conn.close()
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ class UpdateReplication:
|
||||
replication.init_replication(conn, base_url=args.config.REPLICATION_URL)
|
||||
if args.update_functions:
|
||||
LOG.warning("Create functions")
|
||||
refresh.create_functions(conn, args.config, args.data_dir,
|
||||
refresh.create_functions(conn, args.config, args.sqllib_dir,
|
||||
True, False)
|
||||
conn.close()
|
||||
return 0
|
||||
|
||||
@@ -26,6 +26,7 @@ def run_legacy_script(script, *args, nominatim_env=None, throw_on_fail=False):
|
||||
env = nominatim_env.config.get_os_env()
|
||||
env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
|
||||
env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
|
||||
env['NOMINATIM_SQLDIR'] = str(nominatim_env.sqllib_dir)
|
||||
env['NOMINATIM_DATABASE_MODULE_SRC_PATH'] = nominatim_env.module_dir
|
||||
if not env['NOMINATIM_OSM2PGSQL_BINARY']:
|
||||
env['NOMINATIM_OSM2PGSQL_BINARY'] = nominatim_env.osm2pgsql_path
|
||||
|
||||
@@ -8,17 +8,17 @@ from psycopg2.extras import execute_values
|
||||
|
||||
from ..db.utils import execute_file
|
||||
|
||||
def update_postcodes(conn, datadir):
|
||||
def update_postcodes(conn, sql_dir):
|
||||
""" Recalculate postcode centroids and add, remove and update entries in the
|
||||
location_postcode table. `conn` is an opne connection to the database.
|
||||
"""
|
||||
execute_file(conn, datadir / 'sql' / 'update-postcodes.sql')
|
||||
execute_file(conn, sql_dir / 'update-postcodes.sql')
|
||||
|
||||
|
||||
def recompute_word_counts(conn, datadir):
|
||||
def recompute_word_counts(conn, sql_dir):
|
||||
""" Compute the frequency of full-word search terms.
|
||||
"""
|
||||
execute_file(conn, datadir / 'sql' / 'words_from_search_name.sql')
|
||||
execute_file(conn, sql_dir / 'words_from_search_name.sql')
|
||||
|
||||
|
||||
def _add_address_level_rows_from_entry(rows, entry):
|
||||
@@ -153,12 +153,10 @@ def _get_partition_function_sql(conn, sql_dir):
|
||||
|
||||
return replace_partition_string(sql, sorted(partitions))
|
||||
|
||||
def create_functions(conn, config, data_dir,
|
||||
def create_functions(conn, config, sql_dir,
|
||||
enable_diff_updates=True, enable_debug=False):
|
||||
""" (Re)create the PL/pgSQL functions.
|
||||
"""
|
||||
sql_dir = data_dir / 'sql'
|
||||
|
||||
sql = _get_standard_function_sql(conn, config, sql_dir,
|
||||
enable_diff_updates, enable_debug)
|
||||
sql += _get_partition_function_sql(conn, sql_dir)
|
||||
|
||||
Reference in New Issue
Block a user