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

Joined
Oct 25, 2018
Messages
1
Reaction score
0
Hi,

I am trying to connect the Oracle database from Python IDLE with below code but getting an error.
Can anyone help me on this.
import cx_Oracle

conn = cx_Oracle.connect('hr/hr@Sony-PC/XE')
print(conn)

Error:
Traceback (most recent call last):
File "D:/Python/25_10(2).py", line 3, in <module>
conn = cx_Oracle.connect('hr/hr@Sony-PC/XE')
cx_Oracle.DatabaseError: ORA-12154: TNS:could not resolve the connect identifier specified

I have done the below prerequisites before executing the code.
1.Installed Oracle 11 g 64 bit Express edition.(created username/password: hr/hr)
2.Installed Python 3.7.1 64 bit.(automatically the PATH has been set)
3.Installed the cx_Oracle package using below command.
python -m pip install cx_Oracle --upgrade pip
(currently this is having 18.1 version)
4.Downloaded the Oracle Instant client 64 bit and set the PATH in system variable. ;C:\instantclient-basic-windows.x64-11.2.0.4.0\instantclient_11_2
5.Installed the Microsoft Windows Redistributables for client library.
6.Tried executing the below code but getting error.
import cx_Oracle
conn = cx_Oracle.connect('hr/hr@Sony-PC/XE')
print(conn)
Note : attached is the TNS file content. Please refer

Thanks,
Dinesh
 

Attachments

  • TNS.jpg
    TNS.jpg
    101.6 KB · Views: 704

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top