1 # SPDX-License-Identifier: GPL-2.0-only
3 # This file is part of Nominatim. (https://nominatim.org)
5 # Copyright (C) 2022 by the Nominatim developer community.
6 # For a full list of authors see the git log.
8 Query and access functions for the in-database property table.
11 def set_property(conn, name, value):
12 """ Add or replace the propery with the given name.
14 with conn.cursor() as cur:
15 cur.execute('SELECT value FROM nominatim_properties WHERE property = %s',
19 sql = 'INSERT INTO nominatim_properties (value, property) VALUES (%s, %s)'
21 sql = 'UPDATE nominatim_properties SET value = %s WHERE property = %s'
23 cur.execute(sql, (value, name))
26 def get_property(conn, name):
27 """ Return the current value of the given propery or None if the property
30 if not conn.table_exists('nominatim_properties'):
33 with conn.cursor() as cur:
34 cur.execute('SELECT value FROM nominatim_properties WHERE property = %s',
37 return cur.fetchone()[0] if cur.rowcount > 0 else None