11import base64
22import json
33import urllib .parse
4+ from decimal import Decimal
45from typing import Any
56
67from sqlalchemy import create_engine , text , Result , Engine
910from apps .datasource .models .datasource import DatasourceConf , CoreDatasource , TableSchema , ColumnSchema
1011from apps .datasource .utils .utils import aes_decrypt
1112from apps .db .engine import get_engine_config
12- from decimal import Decimal
13-
1413from apps .system .crud .assistant import get_ds_engine
1514from 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