I am having serious issues setting up a proper tunnel in paramiko to enable a database connection. I have reviewed the example 'forward.py', but am not understanding how to then link the database connection to it. Any pointers woudl be much appreciated.
I think I need something the following:
t = paramiko.Transport((hostname, port))
t.connect(username=username, password=password, hostkey=hostkey)
c = paramiko.Channel(t)
#something about assigning a local port to this connection
connection = psycopg2.connect(connectionstring)
#and do my stuff
connection.close()
c.close()
t.close()