move update code for postcode and word count to Python

Adds also tests for the new function to execute a SQL script.
This commit is contained in:
Sarah Hoffmann
2021-01-22 23:25:37 +01:00
parent e6d9485c4a
commit e6c2842b66
6 changed files with 114 additions and 44 deletions

View File

@@ -0,0 +1,16 @@
"""
Functions for bringing auxiliary data in the database up-to-date.
"""
from ..db.utils import execute_file
def update_postcodes(conn, datadir):
""" 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')
def recompute_word_counts(conn, datadir):
""" Compute the frequency of full-word search terms.
"""
execute_file(conn, datadir / 'sql' / 'words_from_search_name.sql')