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 : Below is the TNS file content. Please refer
Thanks,
Dinesh
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Sony-PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
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 : Below is the TNS file content. Please refer
Thanks,
Dinesh
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Sony-PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)