3

I want to connect to remote oracle db using python. Tried to using cx_Oracle.

Here is my code:

import cx_Oracle

adr = 'server_addres'
uid = 'user_id'
pwd = 'pwd'
port = 'port'

cx_Oracle.connect(uid + "/" + pwd + "@" + adr)

After execute, I am receiving error:

cx_Oracle.DatabaseError: ORA-12154: TNS: could not resolve the connect identifier specified

How to connect to my remote oracle db? Or maybe I should use something different than cx_Oracle?

3
  • I think this has already been answered here: stackoverflow.com/a/1870849/1917858 Commented May 17, 2018 at 4:49
  • I already tried this resolution, but it isn't working for me. Still the same error. Commented May 17, 2018 at 5:00
  • 1
    Ok, i found the reason. In my db address i put '//' at the begging. Now, after deleted '//' it works. So stackoverflow.com/a/1870849/1917858 works fine. Thanks. Commented May 17, 2018 at 5:07

1 Answer 1

0

import cx_Oracle conn = cx_Oracle.connect(user="User_id", password="User_password", dsn="the_ip_address/XE", encoding="UTF-8") print(conn.version) conn.close()

It gave me output as 18.0.0.0.0 which is my oracle version

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.