0

So I'm trying to establish a connection to a remote Oracle Database in python, from a Linux CentOS machine, but I'm getting the error- cx_Oracle.DatabaseError: ORA-12170: TNS:Connect timeout occurred.

I'm using a virtual environment to run my code, wherein I have installed the cx-Oracle==8.3.0. My python version is 3.6.2 and below is my code

import cx_Oracle

username ="username" password ="password"

tns_dsn = cx_Oracle.makedsn("examplehost.com", 1528, "SID")

connection = cx_Oracle.connect( username, password, tns_dsn)

print(connection.version)

I've also tried connection = cx_Oracle.connect("username/password@examplehost.com:1528/SID") and possibly many other ways of connecting to the database, all have given me the same error.

I read other similar questions, some said to modify tnsnames.ora which I can't find anywhere on the system, as I'm using a virtual to implement this.

Please let me know where I'm going wrong or if I'm missing something.

Thanks

aikyab
  • 1
  • Look at answers to other posts such as https://stackoverflow.com/questions/23970158/ora-12170-tnsconnect-timeout-occurred – Christopher Jones Jul 01 '22 at 22:19
  • Also look at upgrading Python, since 3.6 is not supported by upstream. And upgrade cx_Oracle, see the latest [release announcement](https://cjones-oracle.medium.com/open-source-python-thin-driver-for-oracle-database-e82aac7ecf5a). – Christopher Jones Jul 01 '22 at 22:20

0 Answers0