Essentially, what you're aiming for is to open a TCP port on a local machine which connects to the MySQL database running on a remote machine; with the traffic tunneled through SSH.
I'm assuming you can already connect to the remove machine via SSH; that's a different question all together. I don't have Windows, so bare with me, but here's how to setup the tunnel in Putty: https://the.earth.li/~sgtatham/putty/0.67/htmldoc/Chapter3.html#using-port-forwarding
To configure the tunnel you need to...
- Know the port MySQL is listening on.
- Choose a local port to connect to (if you don't have MySQL running locally, you can use the same port number.
Once the tunnel is open, configure your MySQL connection in Python to use the local port.
For example, if you were connecting with the MySQL client the command would look like this: mysql -uUSER -pPASSWORD --port LOCAL_PORT DATABASE
. That would establish a connection with localhost, which SSH will intercept and forward to the remote MySQL instance.