Can somebody tell me what is wrong with this code. I am able to connect via SSH on the commandline, but this does not want to work The error message i am getting is:
2019-11-24 13:35:32,304| ERROR | Could not open connection to gateway
Traceback (most recent call last):
File "sshpythonanywhere2.py", line 11, in <module>
remote_bind_address=('Pipsy100.mysql.pythonanywhere-services.com', 3306)
File "C:\anaconda\lib\site-packages\sshtunnel.py", line 1552, in __enter__
self.start()
File "C:\anaconda\lib\site-packages\sshtunnel.py", line 1294, in start
reason='Could not establish session to SSH gateway')
File "C:\anaconda\lib\site-packages\sshtunnel.py", line 1100, in _raise
raise exception(reason)
sshtunnel.BaseSSHTunnelForwarderError: Could not establish session to SSH gateway
import mysql.connector
import sshtunnel
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='Pipsy100', ssh_password='XXXXXXX',
remote_bind_address=('Pipsy100.mysql.pythonanywhere-services.com', 3306)
) as tunnel:
connection = mysql.connector.connect(
user='Pipsy100', password='XXXXXXX',
host='127.0.0.1', port=tunnel.local_bind_port,
database='Pipsy100$mysite',
)
mycursor = connection.cursor()
mycursor.execute("CREATE TABLE customers (name VARCHAR(255), address VARCHAR(255))")
mycursor.close()
connection.close()
[edited by admin: formatting]