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

11
nominatim/db/utils.py Normal file
View File

@@ -0,0 +1,11 @@
"""
Helper functions for handling DB accesses.
"""
def execute_file(conn, fname):
""" Read an SQL file and run its contents against the given connection.
"""
with fname.open('r') as fdesc:
sql = fdesc.read()
with conn.cursor() as cur:
cur.execute(sql)