Oh I think I just connected by ssh normally! Installed openssh-server, entered 'ssh alexjayclark@ssh.pythonanywhere.com' and then my password - and looks like it connected all OK...
Have run my script again though and still hanging. This is the code I've got (have blanked out password obviously!):
import mysql.connector
import sshtunnel
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
print('CONNECTING TO DATABASE')
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='alexjayclark', ssh_password='XXXXX',
remote_bind_address=('alexjayclark.mysql.pythonanywhere-services.com', 3306)
) as tunnel:
connection = mysql.connector.connect(
user='alexjayclark', password='XXXX',
host='127.0.0.1', port=tunnel.local_bind_port,
database='alexjayclark$default',
)
print("CONNECTED")
mycursor = mydb.cursor()
mycursor.execute("SHOW TABLES")
for x in mycursor:
print(x)
connection.close()