如何在远程机器中用Python连接Oracle数据源?
我正在尝试在远程计算机中使用 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,
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题已解决。
我从链接 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.