X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/5071710db7832d13341230c9942bc7030a0ec6dc..8b1a509442a3fa051146f82b8293126916ad8617:/nominatim/db/async_connection.py diff --git a/nominatim/db/async_connection.py b/nominatim/db/async_connection.py index 361fe075..a4f55496 100644 --- a/nominatim/db/async_connection.py +++ b/nominatim/db/async_connection.py @@ -48,14 +48,14 @@ class DBConnection: """ A single non-blocking database connection. """ - def __init__(self, dsn): + def __init__(self, dsn, cursor_factory=None): self.current_query = None self.current_params = None self.dsn = dsn self.conn = None self.cursor = None - self.connect() + self.connect(cursor_factory=cursor_factory) def close(self): """ Close all open connections. Does not wait for pending requests. @@ -66,7 +66,7 @@ class DBConnection: self.conn = None - def connect(self): + def connect(self, cursor_factory=None): """ (Re)connect to the database. Creates an asynchronous connection with JIT and parallel processing disabled. If a connection was already open, it is closed and a new connection established. @@ -79,7 +79,7 @@ class DBConnection: self.conn = psycopg2.connect(**{'dsn' : self.dsn, 'async' : True}) self.wait() - self.cursor = self.conn.cursor() + self.cursor = self.conn.cursor(cursor_factory=cursor_factory) # Disable JIT and parallel workers as they are known to cause problems. # Update pg_settings instead of using SET because it does not yield # errors on older versions of Postgres where the settings are not