eschutho commented on code in PR #21912:
URL: https://github.com/apache/superset/pull/21912#discussion_r1026958181


##########
superset/models/core.py:
##########
@@ -368,14 +372,41 @@ def get_sqla_engine_with_context(
         schema: Optional[str] = None,
         nullpool: bool = True,
         source: Optional[utils.QuerySource] = None,
+        ssh_tunnel: Optional["SSHTunnel"] = None,
     ) -> Engine:
-        yield self._get_sqla_engine(schema=schema, nullpool=nullpool, 
source=source)
+        ssh_params = {}
+        if ssh_tunnel:
+            # build with override
+            url = make_url_safe(self.sqlalchemy_uri_decrypted)
+            ssh_tunnel.bind_host = url.host
+            ssh_tunnel.bind_port = url.port
+            ssh_params = ssh_tunnel.parameters()
+            try:
+                with sshtunnel.open_tunnel(**ssh_params) as server:
+                    yield self._get_sqla_engine(
+                        schema=schema,
+                        nullpool=nullpool,
+                        source=source,
+                        ssh_tunnel_server=server,
+                    )
+            except Exception as ex:
+                raise ex

Review Comment:
   why are we catching and reraising the same thing here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to