From: AntoJvlt Date: Tue, 8 Jun 2021 07:33:10 +0000 (+0200) Subject: Use place_exists() into can_compute() for postcodes X-Git-Tag: v4.0.0~64^2~4 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/47fb7cd3a8c24b232288a31c4ca89e4bc187b01f?hp=--cc Use place_exists() into can_compute() for postcodes --- 47fb7cd3a8c24b232288a31c4ca89e4bc187b01f diff --git a/nominatim/tools/postcodes.py b/nominatim/tools/postcodes.py index fd355079..3ab59d59 100644 --- a/nominatim/tools/postcodes.py +++ b/nominatim/tools/postcodes.py @@ -9,7 +9,7 @@ from math import isfinite from psycopg2.extras import execute_values -from nominatim.db.connection import connect +from nominatim.db.connection import _Connection, connect LOG = logging.getLogger() @@ -203,9 +203,5 @@ def can_compute(dsn): Check that the place table exists so that postcodes can be computed. """ - with connect(dsn) as conn: - with conn.cursor() as cur: - cur.execute(""" - select exists(select 1 from information_schema.tables where table_name='place') - """) - return cur.fetchone()[0] + with _Connection(dsn) as conn: + return conn.table_exists('place')