This may be a repeated question of attempting to run a mysql query on a remote machine using python. Im using pymysql and SSHTunnelForwarder for this.
The mysqldb is located on different server (192.168.10.13 and port 5555).
Im trying to use the following snippet:
with SSHTunnelForwarder(
(host, ssh_port),
ssh_username = ssh_user,
ssh_password = ssh_pass,
remote_bind_address=('127.0.0.1', 5555)) as server:
with pymysql.connect("192.168.10.13", user, password, port=server.local_bind_port) as connection:
cursor = connection.cursor()
output = cursor.execute("select * from billing_cdr limit 1")
print output
Is this the correct approach ?
I see the following error:
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
Also is there any other recommended library to use ?