如何在远程机器中用Python连接Oracle数据源?

发布于 2025-01-11 13:28:35 字数 892 浏览 0 评论 0原文

我正在尝试在远程计算机中使用 Python 连接 Oracle 数据源。 我的python版本和cx_Oracle详细信息如下, 输入图片这里的描述

这是我连接Oracle的代码,

import cx_Oracle

dsn_tns = cx_Oracle.makedsn('host_name', 'port', service_name='service_name') 
conn = cx_Oracle.connect(user='user', password='pws', dsn=dsn_tns) 
c = conn.cursor()
c.execute('select * from DB.TABLE')

for row in c:
   print(row[0])

conn.close()

即使python和Oracle都是32位,我也遇到了32位Oracle客户端库问题。

Exception has occurred: DatabaseError
DPI-1047: Cannot locate a 32-bit Oracle Client library: "The specified module could not be found". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help

谁能帮我解决这个问题吗?

不太确定如何在远程计算机中管理它。如果您建议在终端上运行命令,那么我在远程计算机上处​​理就会很容易。

I am trying to connect Oracle datasource using Python in my remote machine.
My python version and cx_Oracle details as follows,
enter image description here

here is my code to connect Oracle,

import cx_Oracle

dsn_tns = cx_Oracle.makedsn('host_name', 'port', service_name='service_name') 
conn = cx_Oracle.connect(user='user', password='pws', dsn=dsn_tns) 
c = conn.cursor()
c.execute('select * from DB.TABLE')

for row in c:
   print(row[0])

conn.close()

Even python and Oracle are 32 bits, I am getting 32 bit Oracle client library issues.

Exception has occurred: DatabaseError
DPI-1047: Cannot locate a 32-bit Oracle Client library: "The specified module could not be found". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help

Can anyone please help me to resolve this issue?

Not really sure how to manage this in remote machine. If you suggest the commands to run on terminals it would be easy for me to deal in remote machine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赢得她心 2025-01-18 13:28:35

问题已解决。
我从链接 https://www.oracle.com/in/database/technologies/instant-client/microsoft-windows-32-downloads.html(基本包)和在环境变量中设置 PATH 解决了我的问题。

The issue fixed.
I downloaded 32 bit Oracle Instant client files(zip) from the link https://www.oracle.com/in/database/technologies/instant-client/microsoft-windows-32-downloads.html (Basic package) and set the PATH in environment variables solved my problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文