From f6253cdb0ce6c2d129d0db532895965507ab84f1 Mon Sep 17 00:00:00 2001 From: junjun Date: Tue, 29 Jul 2025 12:00:03 +0800 Subject: [PATCH] feat: connect --- backend/apps/db/db.py | 14 ++++---------- backend/apps/db/engine.py | 4 +--- backend/apps/system/crud/assistant.py | 14 ++++---------- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index 83be9c75..ede3d277 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -60,20 +60,14 @@ def get_engine(ds: CoreDatasource, timeout: int = 30) -> Engine: engine = create_engine(get_uri(ds), connect_args={"options": f"-c search_path={urllib.parse.quote(conf.dbSchema)}", "connect_timeout": conf.timeout}, - pool_timeout=conf.timeout, pool_size=20, max_overflow=10) + pool_timeout=conf.timeout) elif ds.type == 'sqlServer': - engine = create_engine(get_uri(ds), pool_timeout=conf.timeout, - pool_size=20, - max_overflow=10) + engine = create_engine(get_uri(ds), pool_timeout=conf.timeout) elif ds.type == 'oracle': engine = create_engine(get_uri(ds), - pool_timeout=conf.timeout, - pool_size=20, - max_overflow=10) + pool_timeout=conf.timeout) else: - engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout, - pool_size=20, - max_overflow=10) + engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout) return engine diff --git a/backend/apps/db/engine.py b/backend/apps/db/engine.py index e86756f5..f4c95274 100644 --- a/backend/apps/db/engine.py +++ b/backend/apps/db/engine.py @@ -25,9 +25,7 @@ def get_engine_conn(): db_url = get_engine_uri(conf) engine = create_engine(db_url, connect_args={"options": f"-c search_path={conf.dbSchema}", "connect_timeout": conf.timeout}, - pool_timeout=conf.timeout, - pool_size=20, - max_overflow=10) + pool_timeout=conf.timeout) return engine diff --git a/backend/apps/system/crud/assistant.py b/backend/apps/system/crud/assistant.py index 72bdfa57..090c4f1b 100644 --- a/backend/apps/system/crud/assistant.py +++ b/backend/apps/system/crud/assistant.py @@ -213,18 +213,12 @@ def get_ds_engine(ds: AssistantOutDsSchema) -> Engine: engine = create_engine(uri, connect_args={"options": f"-c search_path={urllib.parse.quote(ds.db_schema)}", "connect_timeout": timeout}, - pool_timeout=timeout, pool_size=20, max_overflow=10) + pool_timeout=timeout) elif ds.type == 'sqlServer': - engine = create_engine(uri, pool_timeout=timeout, - pool_size=20, - max_overflow=10) + engine = create_engine(uri, pool_timeout=timeout) elif ds.type == 'oracle': engine = create_engine(uri, - pool_timeout=timeout, - pool_size=20, - max_overflow=10) + pool_timeout=timeout) else: - engine = create_engine(uri, connect_args={"connect_timeout": timeout}, pool_timeout=timeout, - pool_size=20, - max_overflow=10) + engine = create_engine(uri, connect_args={"connect_timeout": timeout}, pool_timeout=timeout) return engine