From efd563b7e11026bcf40d3a417e0332cc7868f168 Mon Sep 17 00:00:00 2001 From: index-git Date: Mon, 25 Sep 2023 14:12:34 +0200 Subject: [PATCH] FixUp --- src/db/util.py | 8 +++----- src/layman/layer/db/__init__.py | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/db/util.py b/src/db/util.py index 3bbf81218..78b91689c 100644 --- a/src/db/util.py +++ b/src/db/util.py @@ -19,7 +19,7 @@ def get_connection_pool(db_uri_str=None, encapsulate_exception=True): if not connection_pool: db_uri_parsed = parse.urlparse(db_uri_str) try: - connection_pool = psycopg2.pool.ThreadedConnectionPool(5, 50, + connection_pool = psycopg2.pool.ThreadedConnectionPool(3, 20, user=db_uri_parsed.username, password=db_uri_parsed.password, host=db_uri_parsed.hostname, @@ -51,8 +51,7 @@ def run_query(query, data=None, uri_str=None, encapsulate_exception=True, log_qu raise Error(2) from exc raise exc finally: - if pool and conn: - pool.putconn(conn) + pool.putconn(conn) return rows @@ -74,8 +73,7 @@ def run_statement(query, data=None, uri_str=None, encapsulate_exception=True, lo raise Error(2) from exc raise exc finally: - if pool and conn: - pool.putconn(conn) + pool.putconn(conn) return rows diff --git a/src/layman/layer/db/__init__.py b/src/layman/layer/db/__init__.py index ad7b9213f..75ffa835c 100644 --- a/src/layman/layer/db/__init__.py +++ b/src/layman/layer/db/__init__.py @@ -406,7 +406,7 @@ def get_most_frequent_lower_distance(schema, table_name, primary_key, geometry_c # print(query) try: - rows = db_util.run_query(query, uri_str) + rows = db_util.run_query(query, uri_str=uri_str) except BaseException as exc: logger.error(f'get_most_frequent_lower_distance ERROR') raise LaymanError(7) from exc