Open SSH tunnel to MySQL if specified.
This commit is contained in:
parent
6a99fff921
commit
104d95bc5a
1 changed files with 8 additions and 1 deletions
|
|
@ -115,8 +115,15 @@ def get_connection_to_mysql(
|
|||
:param connection_config: specifies host, port, etc.
|
||||
:return: the connection object
|
||||
"""
|
||||
if connection_config["ssh_tunneling"]["use_tunnel"]:
|
||||
open_ssh_tunnel(connection_config)
|
||||
mysql_connection_host = "127.0.0.1"
|
||||
|
||||
if not connection_config["ssh_tunneling"]["use_tunnel"]:
|
||||
mysql_connection_host = connection_config["host"]
|
||||
|
||||
connection = mysql.connector.connect(
|
||||
host=connection_config["host"],
|
||||
host=mysql_connection_host,
|
||||
port=connection_config["port"],
|
||||
user=connection_config["user"],
|
||||
password=connection_config["password"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue