Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access an Oracle db without installing Oracle's client and cx_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.

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

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')

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?

Thanks in advance!

like image 312
Gary Avatar asked Oct 02 '13 17:10

Gary


People also ask

Does cx_Oracle require Oracle client?

cx_Oracle requires Oracle Client libraries. The libraries provide the necessary network connectivity to access an Oracle Database instance. They also provide basic and advanced connection management and data features to cx_Oracle.

Can we use SQL Developer without Oracle client?

SQL Developer comes with the Oracle JDBC Driver, so you don't need anything else to connect after you unzip the download to it's new home.


2 Answers

An excerpt from https://forum.omz-software.com/topic/184/oracle-database:

There's no pure python client for Oracle and likely never will be. Even wonderful third-party toolsets like SQLalchemy still rely on cx_Oracle underneath to do the actual communication to the Oracle database servers.

—also, deciding by Google, the answer is no: there do not seem to be any pure Python Oracle clients in existence as of today.

like image 73
Erik Kaplun Avatar answered Sep 22 '22 05:09

Erik Kaplun


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

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.

like image 38
user632657 Avatar answered Sep 22 '22 05:09

user632657