如何在不安装Oracle客户端和cx_Oracle的情况下访问Oracle数据库? [英] How do I access an Oracle db without installing Oracle's client and cx_Oracle?

查看:349
本文介绍了如何在不安装Oracle客户端和cx_Oracle的情况下访问Oracle数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个分别运行Python 2.4和2.6的RHEL服务器.我需要访问的另一台服务器上有一个Oracle数据库.

I have two RHEL servers running Python 2.4 and 2.6 separately. There is an Oracle database on the other server I need to access.

我试图在RHEL服务器上安装cx_oracle,但发现必须首先安装Oracle客户端.

I was trying to install cx_oracle on my RHEL server but found out that the Oracle client must be installed first.

问题是,我没有权限在两台RHEL服务器上安装Oracle客户端.在同一服务器上,Perl程序可以使用以下命令连接到Oracle数据库:

The problem is, I don’t have permission to install Oracle's client on both RHEL servers. On the same servers, a Perl program can connect to the Oracle db using:

DBI->connect("dbi:Oracle:host=myhost.prod.com;sid=prddb",'username','password')

在不安装cx_oracle和Oracle客户端的情况下,Python可以这样做吗?还是有一些关于如何自己编写模块以完成相同操作的建议?

Can Python do the same without installing cx_oracle and the Oracle client? Or are there any suggestions about how to write a module myself to do the same thing?

提前谢谢!

推荐答案

通常,您需要的只是库,它们不一定需要sudo权限.将它们提取到软件可以读取的位置,并相应地设置以下环境变量:

Usually, all you need are the libraries, which don't necessarily require sudo rights. Extract them to a place the software will be able to read from and set the following environment variables accordingly:

ORACLE_HOME=path/to/where/you/extracted/libs
TNS_ADMIN=path/to/tnsnames.ora

我最幸运的是跳过tnsname,仅在连接中指定主机,端口等,但是很有可能您需要cx_oracle ...我不记得我使用它的年龄了

I have had best luck skipping tnsnames, and just specifying the host, port, etc in the connection, but it's quite possible you'll need it for cx_oracle...I don't remember from when I used it ages ago.

这篇关于如何在不安装Oracle客户端和cx_Oracle的情况下访问Oracle数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆