I'm trying to get a connection from python (3.7)
to a remote oracle
DB using the code below:
import cx_Oracle # Version 7.2.2
import sshtunnel
import socket
HOST = "HOST"
USRNAME = "Me"
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
with sshtunnel.SSHTunnelForwarder(
(HOST, 22),
ssh_username = USRNAME,
ssh_pkey='~/.ssh/dumpserver',
remote_bind_address=(IPAddr, 22)
) as server:
conn = cx_Oracle.connect('testuser','password', 'oracle/db', encoding="UTF-8")
print(conn.version)
I get the following ERROR:
DatabaseError: ORA-12170: TNS:Connect timeout occurred.
I've tried to read up on this at
- https://cx-oracle.readthedocs.io/en/latest/user_guide/connection_handling.html
- cx_Oracle & Connecting to Oracle DB Remotely
- https://github.com/oracle/python-cx_Oracle/issues/158
But did not get any smarter and I can't get it to work :( Any ideas pointers etc. are very welcome. Also if someone has alternative code snipets on how to send an oracle query to remote - f.eks using paramiko
that would be great.
Thanks, F