Skip to content

Commit

Permalink
Refactor: Simplify retrieval of username and password in remote conne…
Browse files Browse the repository at this point in the history
…ction
  • Loading branch information
LeoQuote committed Feb 28, 2025
1 parent b4f9465 commit aeacfae
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions sql/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __del__(self):
del self.remotessh

def remote_instance_conn(self, instance=None):
user, password = instance.get_username_password()
# 判断如果配置了隧道则连接隧道
if not hasattr(self, "remotessh") and instance.tunnel:
self.remotessh = SSHConnection(
Expand All @@ -62,13 +63,14 @@ def remote_instance_conn(self, instance=None):
instance.tunnel.pkey_password,
)
self.remote_host, self.remote_port = self.remotessh.get_ssh()
self.remote_user = self.user
self.remote_password = self.password
user, password = instance.get_username_password()
self.remote_user = user
self.remote_password = password
elif not instance.tunnel:
self.remote_host = instance.host
self.remote_port = instance.port
self.remote_user = self.user
self.remote_password = self.password
self.remote_user = user
self.remote_password = password
return (
self.remote_host,
self.remote_port,
Expand Down

0 comments on commit aeacfae

Please sign in to comment.