我一直在尝试使用Visual Studio中的Python访问Oracle数据库。至于现在,在这个数据库中我知道我的用户名和密码,id和端口。没什么。
我现在所做的是:
写了这段代码
IP = 'IPADDRESS' 端口= 1521 SID = 'XE' dsn_tns = cx_Oracle.makedsn(IP,端口SID) db = cx_Oracle.connect('username','password',dns_tns)
目前我一直收到这个错误:
TNS-12505:TNS:侦听器当前不知道连接描述符中给出的SID
并无法找到解决方案;在线阅读它似乎与listener.ora有关,但我无法找到适合我的解决方案。
这是
LISTNER.ORA
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = gvd-server.GLITRE-NETT.local)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
和tnsnames.ora
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = gvd-server.GLITRE-NETT.local)(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)
)
)
我感谢任何帮助,并提前感谢大家。 祝你有美好的一天!