From 660fe41b623ba2057d07c644a8e72380a65a4910 Mon Sep 17 00:00:00 2001 From: Cayo Puigdefabregas Date: Tue, 30 Jan 2024 12:04:17 +0100 Subject: [PATCH] fix change max connections --- ereuse_devicehub/db.py | 5 ++++- ereuse_devicehub/teal/db.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ereuse_devicehub/db.py b/ereuse_devicehub/db.py index 16ede4fc..1a63f431 100644 --- a/ereuse_devicehub/db.py +++ b/ereuse_devicehub/db.py @@ -70,6 +70,9 @@ def create_view(name, selectable): return table -db = SQLAlchemy(session_options={'autoflush': False}) +db = SQLAlchemy( + session_options={'autoflush': False}, + engine_options={"pool_size": 5, "max_overflow": 10} +) f = db.func exp = expression diff --git a/ereuse_devicehub/teal/db.py b/ereuse_devicehub/teal/db.py index 7f0b8c7f..cc863481 100644 --- a/ereuse_devicehub/teal/db.py +++ b/ereuse_devicehub/teal/db.py @@ -240,9 +240,10 @@ class SQLAlchemy(FlaskSQLAlchemy): metadata=None, query_class=BaseQuery, model_class=Model, + engine_options=None, ): super().__init__( - app, use_native_unicode, session_options, metadata, query_class, model_class + app, use_native_unicode, session_options, metadata, query_class, model_class, engine_options ) def create_session(self, options): @@ -266,9 +267,10 @@ class SchemaSQLAlchemy(SQLAlchemy): metadata=None, query_class=Query, model_class=Model, + engine_options=None, ): super().__init__( - app, use_native_unicode, session_options, metadata, query_class, model_class + app, use_native_unicode, session_options, metadata, query_class, model_class, engine_options ) # The following listeners set psql's search_path to the correct # schema and create the schemas accordingly