To enter strings into a keyboard, press carriage return, and have the string append a remote mySQL database

Python Script will not run because sshtunnel import to Python 3 does not seem import properly to the Pi.
I am thinking we are using the wrong version of ssh module python script for the Pi but I am struggling.  

 Hardware :
Raspberry Pi 3 Model B -  V 1.2  2015

OS Software :
pi@raspberrypi:~ $ cat /etc/*-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION="8 (jessie)"

import sshtunnel #import SSHTunnelForwarder
import mysql.connector

ID_String_Last = ["0"]

sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0

with sshtunnel.SSHTunnelForwarder(
    ('**********this is the host in here **********'),
    ssh_username='', ssh_password='**********************',
    remote_bind_address=(',', 3306)
) as tunnel:
    connection = mysql.connector.connect(
        user='*********username**********', password='*****************',
        host='', port=tunnel.local_bind_port,

Python 3.4.2 (/usr/bin/python3)
>>> %Run '17-10- 15 V6.1 Pi mySQL to Ash'
Traceback (most recent call last):
  File "/home/pi/Desktop/17-10- 15 V6.1 Pi mySQL to Ash", line 3, in <module>
    import sshtunnel #import SSHTunnelForwarder
ImportError: No module named 'sshtunnel'

Does anybody know what version of module is required for this platform so that it can  run?
Ingo BrownOwnerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NerdsOfTechTechnology ScientistCommented:
try replacing this line
import sshtunnel #import SSHTunnelForwarder

Open in new window

import sshtunnel 
from sshtunnel import SSHTunnelForwarder

Open in new window

OR, if that doesn't work try:
import paramiko
from sshtunnel import SSHTunnelForwarder

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ingo BrownOwnerAuthor Commented:
Apologies for the delay in response. I will give this a try this afternoon and revert
NerdsOfTechTechnology ScientistCommented:
SSH forwarder should do the trick
Ingo BrownOwnerAuthor Commented:
We could not get the module to work so we assumed we had a OS problem. We downloaded the latest version of  UBUNTU 16.04 LTS to the rasberry pi. When I run sudo -H pip install sshtunnel , I get the following error:
Command "python egg_info" failed with error code 1 in /tmp/pip-build-wmbw0/pynacl/

We are struggling with the module itself it seems
we are such noobs!!
NerdsOfTechTechnology ScientistCommented:

sudo apt-get install python-setuptools
sudo easy_install -U setuptools
sudo pip install --upgrade setuptools
python egg_info

Open in new window

Ingo BrownOwnerAuthor Commented:
We got the modules installed & below is the script that works.

from sshtunnel import SSHTunnelForwarder
import MySQLdb

user_entry = input("Please enter user: ")

with SSHTunnelForwarder(('bo************.com', 22),
                        ssh_password='*****************!', ssh_username='***********',
                        remote_bind_address=('localhost', 3306)) as server:
    conn = MySQLdb.connect('**********', '*****************c', '*****************', '**************')
    cursor = conn.cursor()
    cursor.execute("INSERT INTO log_1001(user) VALUES('%s')" % user_entry)
    cursor.execute("SELECT * FROM log_1001")
    for row in cursor.fetchall():
NerdsOfTechTechnology ScientistCommented:
Thanks for the update!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.