简体   繁体   English

使用带有 cx_oracle 的 Python 连接到 Oracle 数据库

[英]Connecting to Oracle Database Using Python with cx_oracle

I am using cx_oracle to connect the Oracle DB using python.I need your assistance in connecting DB.我正在使用 cx_oracle 使用 python 连接 Oracle DB。在连接 DB 时需要您的帮助。 I'm using following code till date it worked well到目前为止,我一直在使用以下代码,它运行良好

Code-1:代码 1:

import cx_Oracle as cx
dsn_tns = cx.makedsn(HOST,PORT, service_name=SERVICE_NAME)
conn = cx.connect(user=USER, password=PW, dsn=dsn_tns)

Recently TCP port is disabled and we are using jdbc connection string to connect DB which has TCPS port number.can you help where I need to pass the protocol in above/ suggest any other method.最近 TCP 端口被禁用,我们正在使用 jdbc 连接字符串来连接具有 TCPS 端口号的数据库。你能在我需要通过上述协议的地方提供帮助/建议任何其他方法。

i tried following code我尝试了以下代码

code-2:代码 2:

dsn_tns='(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = tcps)(HOST =hostdetails)(PORT =port))) (CONNECT_DATA = (SERVICE_NAME = servicename)))'
conn = cx.connect(user=USER, password=PW, dsn=dsn_tns)
print(cx.version)

I got error: ORA-28759: failure to open file .我收到error: ORA-28759: failure to open file

Any suggestion is appreciated.任何建议表示赞赏。 Thank you in advance.先感谢您。

Does your sqlnet.ora have a WALLET_LOCATION defined?您的 sqlnet.ora 是否定义了 WALLET_LOCATION?

Source . 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM