|
34 | 34 | from common.core.config import settings |
35 | 35 | import sqlglot |
36 | 36 | from sqlglot import expressions as exp |
| 37 | +from sqlalchemy.pool import NullPool |
37 | 38 |
|
38 | 39 | try: |
39 | 40 | if os.path.exists(settings.ORACLE_CLIENT_PATH): |
@@ -139,24 +140,21 @@ def get_engine(ds: CoreDatasource, timeout: int = 0) -> Engine: |
139 | 140 | conf.timeout = timeout |
140 | 141 | if timeout > 0: |
141 | 142 | conf.timeout = timeout |
| 143 | + |
142 | 144 | if equals_ignore_case(ds.type, "pg"): |
143 | 145 | if conf.dbSchema is not None and conf.dbSchema != "": |
144 | 146 | engine = create_engine(get_uri(ds), |
145 | 147 | connect_args={"options": f"-c search_path={urllib.parse.quote(conf.dbSchema)}", |
146 | | - "connect_timeout": conf.timeout}, |
147 | | - pool_timeout=conf.timeout) |
| 148 | + "connect_timeout": conf.timeout}, poolclass=NullPool) |
148 | 149 | else: |
149 | | - engine = create_engine(get_uri(ds), |
150 | | - connect_args={"connect_timeout": conf.timeout}, |
151 | | - pool_timeout=conf.timeout) |
| 150 | + engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool) |
152 | 151 | elif equals_ignore_case(ds.type, 'sqlServer'): |
153 | 152 | engine = create_engine('mssql+pymssql://', creator=lambda: get_origin_connect(ds.type, conf), |
154 | | - pool_timeout=conf.timeout) |
| 153 | + poolclass=NullPool) |
155 | 154 | elif equals_ignore_case(ds.type, 'oracle'): |
156 | | - engine = create_engine(get_uri(ds), |
157 | | - pool_timeout=conf.timeout) |
| 155 | + engine = create_engine(get_uri(ds), poolclass=NullPool) |
158 | 156 | else: # mysql, ck |
159 | | - engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout) |
| 157 | + engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, poolclass=NullPool) |
160 | 158 | return engine |
161 | 159 |
|
162 | 160 |
|
|
0 commit comments