I currently use paramiko to access an SFTP server and connect to the postgreSQL on the same server. I found many examples using sshtunnel to log on postgreSQL but I don't know how to do it with paramiko
currently my code looks something like:
# establish SSH tunnel
self.ssh = paramiko.SSHClient()
self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.ssh.connect(hostname=host, username=user, password=password)
# setup SFTP server
self.sftp = self.ssh.open_sftp()
# connect to datebase
self.engine = create_engine('postgres+psycopg2://{}:{}@{}:{}/{}'.format(user, password, host, port, db))