Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

BaseSSHTunnelForwarderError: Could not establish session to SSH gateway

import mysql.connector
import sshtunnel
import pandas as pd

sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0

with sshtunnel.SSHTunnelForwarder(
    ('ssh.pythonanywhere.com',22),
    ssh_username='myuser', ssh_password='mypass',
    remote_bind_address=('my_user.mysql.pythonanywhere-services.com',3306)
    ) as tunnel:
        connection = mysql.connector.connect(user='myuser', password='mypass',host='127.0.0.1', port=tunnel.local_bind_port,database='myuser$mydb')
        sql = 'SELECT * from history'
        df = pd.read_sql(sql, con=connection)
        print(df.head())
        connection.close()
Comment

PREVIOUS NEXT
Code Example
Python :: assertionerror-accepted-renderer-not-set-on-response-in-django 
Python :: python track time 
Python :: count number of pages in pdf python pdfminer 
Python :: python scheduler 
Python :: add a tuple to a dictionary python 
Python :: insert data in sqlite database in python 
Python :: intersection python dict 
Python :: all possible combinations in python 
Python :: python integer to octal 
Python :: python module location 
Python :: python list contains string 
Python :: run all python files in a directory in bash 
Python :: install scrapy on pycharm 
Python :: python colored text into terminal 
Python :: can serializer returns an object in django 
Python :: data must be 1-dimensional pd.dataframe 
Python :: pyspark read from redshift 
Python :: restart python after script execution 
Python :: how to write a dataframe to s3 object in python 
Python :: How can you hide a tkinter window 
Python :: pytorch squeeze 
Python :: decimal to binary python 
Python :: pandas series example 
Python :: python slice list 
Python :: how to take space separated input in pyhon dicationary 
Python :: python keyboard 
Python :: del list python 
Python :: python list add to start 
Python :: remove french stopwords with spacy 
Python :: ip address finder script python 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =