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?

  • I think this has already been answered here: https://stackoverflow.com/a/1870849/1917858 – Frans Henskens May 17 '18 at 04:49
  • I already tried this resolution, but it isn't working for me. Still the same error. –  May 17 '18 at 05: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. –  May 17 '18 at 05:07

1 Answers1

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