I am trying to connect to a MySQL database on a remote server using MySQLdb in python. The problem is that first I need SSH to the host, and then from there I need to connect to the MySQL server. The problem that comes up with me is that MySQLdb does not seem to have a way to establish an SSH connection before connecting to the SQL server. I checked the documentation, but I was out of luck.
This is how I connect:
conn = MySQLdb.connect(host = 'mysqlhost.domain.com:3306', user = 'user', passwd = 'password', db = 'dbname')
But I really need something like this:
conn = MySQLdb.connect(sshhost = 'sshhost.domain.com', sshuser = 'sshusername', sshpasswd = 'sshpasswd', host = 'mysqlhost.domain.com:3306', user = 'user', passwd = 'password', db = 'dbname')
This, of course, is simply composed. Can anybody give any recommendations?
source share