From 2e26cd3c220b13689dcd74a19bf3690946d54e39 Mon Sep 17 00:00:00 2001 From: junjun Date: Tue, 10 Feb 2026 16:59:35 +0800 Subject: [PATCH] fix: Fix the issue of incorrect data source connection pool recycling --- backend/apps/db/db.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/backend/apps/db/db.py b/backend/apps/db/db.py index e114b1a1..28f43a68 100644 --- a/backend/apps/db/db.py +++ b/backend/apps/db/db.py @@ -34,6 +34,7 @@ from common.core.config import settings import sqlglot from sqlglot import expressions as exp +from sqlalchemy.pool import NullPool try: if os.path.exists(settings.ORACLE_CLIENT_PATH): @@ -139,24 +140,21 @@ def get_engine(ds: CoreDatasource, timeout: int = 0) -> Engine: conf.timeout = timeout if timeout > 0: conf.timeout = timeout + if equals_ignore_case(ds.type, "pg"): if conf.dbSchema is not None and conf.dbSchema != "": 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) + "connect_timeout": conf.timeout}, poolclass=NullPool) else: - engine = create_engine(get_uri(ds), - connect_args={"connect_timeout": conf.timeout}, - pool_timeout=conf.timeout) + engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool) elif equals_ignore_case(ds.type, 'sqlServer'): engine = create_engine('mssql+pymssql://', creator=lambda: get_origin_connect(ds.type, conf), - pool_timeout=conf.timeout) + poolclass=NullPool) elif equals_ignore_case(ds.type, 'oracle'): - engine = create_engine(get_uri(ds), - pool_timeout=conf.timeout) + engine = create_engine(get_uri(ds), poolclass=NullPool) else: # mysql, ck - engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout) + engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool) return engine