X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/a7bd39b62a8c3a179f48715840ee346d93dd0815..f542d65da63cea44b2059913c4bb1c6550506449:/nominatim/db/sql_preprocessor.py diff --git a/nominatim/db/sql_preprocessor.py b/nominatim/db/sql_preprocessor.py index 2e11f571..3762d82e 100644 --- a/nominatim/db/sql_preprocessor.py +++ b/nominatim/db/sql_preprocessor.py @@ -90,6 +90,18 @@ class SQLPreprocessor: self.env.globals['postgres'] = _setup_postgresql_features(conn) + def run_string(self, conn: Connection, template: str, **kwargs: Any) -> None: + """ Execute the given SQL template string on the connection. + The keyword arguments may supply additional parameters + for preprocessing. + """ + sql = self.env.from_string(template).render(**kwargs) + + with conn.cursor() as cur: + cur.execute(sql) + conn.commit() + + def run_sql_file(self, conn: Connection, name: str, **kwargs: Any) -> None: """ Execute the given SQL file on the connection. The keyword arguments may supply additional parameters for preprocessing.