@@ -237,7 +237,8 @@ def get_driver_connection(ds: CoreDatasource | AssistantOutDsSchema, db_config:
237237 )
238238 elif equals_ignore_case (ds .type , 'redshift' ):
239239 if not use_pool :
240- conn = redshift_connector .connect (host = conf .host , port = conf .port , database = conf .database , user = conf .username ,
240+ conn = redshift_connector .connect (host = conf .host , port = conf .port , database = conf .database ,
241+ user = conf .username ,
241242 password = conf .password ,
242243 timeout = conf .timeout , ** conn_conf )
243244 else :
@@ -1175,6 +1176,17 @@ def get_pool(self, ds: CoreDatasource | AssistantOutDsSchema, **db_config):
11751176 print (f"[LRU] create: { ds .id } " )
11761177 return new_pool
11771178
1179+ def remove_pool (self , datasource_id ):
1180+ with self ._lock :
1181+ if datasource_id in self ._pools :
1182+ # 1. 从字典中移除并获取该连接池对象
1183+ pool = self ._pools .pop (datasource_id )
1184+ # 2. 安全关闭该连接池,释放底层所有数据库连接和内存
1185+ pool .close ()
1186+ print (f"[Manager] Closed pool and remove: { datasource_id } " )
1187+ else :
1188+ print (f"[Manager] Warning: ds id { datasource_id } not exist in sqlalchemy" )
1189+
11781190 def close_all (self ):
11791191 """stop"""
11801192 with self ._lock :
@@ -1220,6 +1232,17 @@ def get_pool(self, ds: CoreDatasource | AssistantOutDsSchema, db_config):
12201232 print (f"[LRU] create: { ds .id } " )
12211233 return new_pool
12221234
1235+ def remove_pool (self , datasource_id ):
1236+ with self ._lock :
1237+ if datasource_id in self ._pools :
1238+ # 1. 从字典中移除并获取该连接池对象
1239+ pool = self ._pools .pop (datasource_id )
1240+ # 2. 安全关闭该连接池,释放底层所有数据库连接和内存
1241+ pool .close ()
1242+ print (f"[Manager] Closed pool and remove: { datasource_id } " )
1243+ else :
1244+ print (f"[Manager] Warning: ds id { datasource_id } not exist in dbutils" )
1245+
12231246 def close_all (self ):
12241247 """stop"""
12251248 with self ._lock :
0 commit comments