X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/e1b096cf8cf1ac6904c9adf0963f0e1756ca65ea..185ff683cfc2c6d65ec55a7c05d4cbbf35c077ff:/nominatim/db/connection.py?ds=sidebyside diff --git a/nominatim/db/connection.py b/nominatim/db/connection.py index 4d30151d..c7e22c98 100644 --- a/nominatim/db/connection.py +++ b/nominatim/db/connection.py @@ -50,6 +50,15 @@ class _Connection(psycopg2.extensions.connection): WHERE tablename = %s""", (table, )) return num == 1 + def server_version_tuple(self): + """ Return the server version as a tuple of (major, minor). + Converts correctly for pre-10 and post-10 PostgreSQL versions. + """ + version = self.server_version + if version < 100000: + return (version / 10000, (version % 10000) / 100) + + return (version / 10000, version % 10000) def connect(dsn): """ Open a connection to the database using the specialised connection