Skip to content

Commit bec910c

Browse files
committed
fix: db connect
1 parent 344be80 commit bec910c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

backend/apps/db/db.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import json
33
import urllib.parse
4+
from decimal import Decimal
45
from typing import Any
56

67
from sqlalchemy import create_engine, text, Result, Engine
@@ -9,8 +10,6 @@
910
from apps.datasource.models.datasource import DatasourceConf, CoreDatasource, TableSchema, ColumnSchema
1011
from apps.datasource.utils.utils import aes_decrypt
1112
from apps.db.engine import get_engine_config
12-
from decimal import Decimal
13-
1413
from apps.system.crud.assistant import get_ds_engine
1514
from apps.system.schemas.system_schema import AssistantOutDsSchema
1615

@@ -19,7 +18,8 @@ def get_uri(ds: CoreDatasource) -> str:
1918
conf = DatasourceConf(**json.loads(aes_decrypt(ds.configuration))) if ds.type != "excel" else get_engine_config()
2019
return get_uri_from_config(ds.type, conf)
2120

22-
def get_uri_from_config(type: str,conf: DatasourceConf) -> str:
21+
22+
def get_uri_from_config(type: str, conf: DatasourceConf) -> str:
2323
db_url: str
2424
if type == "mysql":
2525
if conf.extraJdbc is not None and conf.extraJdbc != '':
@@ -61,6 +61,10 @@ def get_engine(ds: CoreDatasource) -> Engine:
6161
connect_args={"options": f"-c search_path={conf.dbSchema}",
6262
"connect_timeout": conf.timeout},
6363
pool_timeout=conf.timeout, pool_size=20, max_overflow=10)
64+
elif ds.type == 'oracle' or ds.type == 'sqlServer':
65+
engine = create_engine(get_uri(ds), pool_timeout=conf.timeout,
66+
pool_size=20,
67+
max_overflow=10)
6468
else:
6569
engine = create_engine(get_uri(ds), connect_args={"connect_timeout": conf.timeout}, pool_timeout=conf.timeout,
6670
pool_size=20,

0 commit comments

Comments
 (0)