I use Toad to connect to my Oracle database and that works fine however I am trying to use cx_Oracle to connect to the same database and my program gets stuck at the .connect()
method.
I believe the issue is the host
name but I cant be sure as no errors exist just does not get past the connect()
call.
import cx_Oracle
CONN_INFO = {'host': '\\\\SERVERNAMEUSEDINTOAD\\',
'port': 1111,
'user': 'USER123',
'psw': 'password',
'service': 'dbname.somesite.com'}
print("test1")
CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)
print("test2")
con = cx_Oracle.connect(CONN_STR)
print("test3")
print(con.fetchmany([1]))
Console:
test1
test2
I make it to test2
but not test3
. Am I using the host name correctly? The host is an internal server on the network.
TOAD application displays just SERVERNAMEUSEDINTOAD
so I tried that as well:
'host': 'SERVERNAMEUSEDINTOAD'
But this resulted in the following error:
test1
test2
Traceback (most recent call last):
File "C:/Users/name/PycharmProjects/WorkFlow/test.py", line 12, in <module>
con = cx_Oracle.connect(CONN_STR)
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified